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

Matching of a reified type does not work properly (in interpreter and compile) #708

Closed
PaulKlint opened this issue Nov 19, 2014 · 4 comments

Comments

@PaulKlint
Copy link
Member

Reported by @tvdstorm:

module experiments::Compiler::Examples::Tst

value main(list[value] args) = type(\int(), _) := #int;

gives with the interpreter

rascal>main([])
value: false   <=== should be true

and with the compiler it gives a static error (but should be accepted):

rascal>execute(|rascal:///experiments/Compiler/Examples/Tst.rsc|, [], recompile=true)
...
error("Cannot match an expression of type: reified[int] against a pattern of type reified[value]",|project://rascal/src/org/rascalmpl/library/experiments/Compiler/Examples/Tst.rsc|(76,15,<3,31>,<3,46>))

@mahills can you have a look at this type checker issue?

@mahills
Copy link
Member

mahills commented Dec 12, 2014

This appears to be because Type needs to be imported in order to get the various constructors that are used (e.g., \int()) in the matches. If I do that, this works fine.

@jurgenvinju
Copy link
Member

The type checker should then complain about the undefined int() constructor in the pattern.

@mahills
Copy link
Member

mahills commented Dec 12, 2014

Agreed, given the way the pattern matching code works the type checker tends to "hide" messages that come out of it, since this could lead to a number of spurious messages, but it's sometimes hiding these too well. I'll look at rebalancing this.

@PaulKlint
Copy link
Member Author

We now get a good message: The declaration for constructor or production int is not in scope

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

3 participants