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

TC infers incorrect type for catch clause consisting of only a qualifiedName #781

Closed
PaulKlint opened this issue Mar 6, 2015 · 2 comments

Comments

@PaulKlint
Copy link
Member

Given

try {
    throw "exception";
} 
catch s:
    return true;

the type checker decides that s has type adt("RuntimeException",[]) but this should be value.

The case of a typed variable works well, e.g., catch str s will result in s having type str.

[Note: this case is now temporarily solved in the compiler]

@mahills
Copy link
Member

mahills commented Mar 7, 2015

I'm guessing this is because, at one point, we assumed that all exceptions were of type RuntimeException. This has never been enforced, though, and in practice we just throw arbitrary values. I just need to adjust to code to do this, assuming we don't want to start enforcing this.

@PaulKlint
Copy link
Member Author

I think the value that is thrown should be of type value. In the cases, one can then match on specific values, including values of type RuntimeException.

As mentioned above, I have a temporary fix in the compiler so there is no hurry for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants