Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve message when type resolution cannot deduce full record type #165

Closed
julianhyde opened this issue Aug 8, 2022 · 0 comments
Closed

Comments

@julianhyde
Copy link
Collaborator

Improve message when type resolution cannot deduce full record type. Currently the expression

fn (e, job) => e.job = job

gives the following stack trace:

java.lang.ClassCastException: class net.hydromatic.morel.type.TypeVar cannot be cast to class net.hydromatic.morel.type.RecordLikeType (net.hydromatic.morel.type.TypeVar and net.hydromatic.morel.type.RecordLikeType are in unnamed module of loader 'app')
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:410)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:323)
	at net.hydromatic.morel.compile.Resolver.lambda$transform$0(Resolver.java:116)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
	at net.hydromatic.morel.compile.Resolver.transform(Resolver.java:116)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:378)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:335)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:405)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:323)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:593)
	at net.hydromatic.morel.compile.Resolver.lambda$transform$0(Resolver.java:116)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
	at net.hydromatic.morel.compile.Resolver.transform(Resolver.java:116)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:440)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:325)
	at net.hydromatic.morel.compile.Resolver.lambda$resolveValDecl$6(Resolver.java:201)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at net.hydromatic.morel.compile.Resolver.resolveValDecl(Resolver.java:199)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:144)
	at net.hydromatic.morel.compile.Resolver.toCore(Resolver.java:123)
	at net.hydromatic.morel.compile.Compiles.prepareDecl(Compiles.java:89)
	at net.hydromatic.morel.compile.Compiles.prepareStatement(Compiles.java:71)

It should instead give the following error:

unresolved flex record (can't tell what fields there are besides #job)

As part of this change, we introduce class TypeResolver.TypeException, and add the method Ml.assertTypeException(String message) to improve the testing of types.

julianhyde added a commit to julianhyde/morel that referenced this issue Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant