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 is too strict in TypedVariableBecomes pattern #473

Closed
PaulKlint opened this issue Dec 31, 2013 · 7 comments
Closed

TC is too strict in TypedVariableBecomes pattern #473

PaulKlint opened this issue Dec 31, 2013 · 7 comments

Comments

@PaulKlint
Copy link
Member

The following gives a type error, but is ok and should only lead to a failure to match certain list elements at runtime:

public value main(list[value] args) =  [ <s,r,L> | list[int] L:[*str s, *str r] <- [ [1,2], ["3","4"] ]];

gives

error("Cannot assign pattern of type list[str] to non-inferred variable L of type list[int]",|rascal:///experiments/Compiler/Examples/Tst.rsc|(96,28,<3,51>,<3,79>))
@swatbot
Copy link

swatbot commented Dec 31, 2013

No, this can never match! List of lists versus sublists. But the error message is confusing. —
Jurgen J. Vinju
CWI SWAT
INRIA Lille
UvA master software engineering
http://jurgen.vinju.org

On Tue, Dec 31, 2013 at 9:39 AM, Paul Klint notifications@github.com
wrote:

The following gives a type error, but is ok and should only lead to a failure to match certain list elements at runtime:

public value main(list[value] args) =  [ <s,r,L> | list[int] L:[*str s, *str r] <- [ [1,2], ["3","4"] ]];

gives

error("Cannot assign pattern of type list[str] to non-inferred variable L of type list[int]",|rascal:///experiments/Compiler/Examples/Tst.rsc|(96,28,<3,51>,<3,79>))

Reply to this email directly or view it on GitHub:
#473

@PaulKlint
Copy link
Member Author

well .. it is in the test set :-)

Indeed, this particular example (there are more of these) will never match, but it should not give a type error.

@tvdstorm
Copy link
Member

I don't see the problem, is it because it says *str s intead of *list[str] s?

@PaulKlint
Copy link
Member Author

The "problem" (= reason for not matching) is that L is declared with type list[int]

@mahills
Copy link
Member

mahills commented Dec 31, 2013

It isn't just a reason for not matching -- you are declaring L as a list[int] and then binding it to a list of strings. That seems like a type problem to me. @jurgenvinju, you are right that this can never match, but that isn't what is generating the error message here.

@PaulKlint
Copy link
Member Author

@mahills you convinced me, this should be a static error; so there is no work involved and we can close this issue.

I am still (too much) inclined to assume that a test case is correct, but on the other hand I have already found dozens of type-incorrect tests.

@swatbot
Copy link

swatbot commented Dec 31, 2013

An issue is that these literals used in tests have a too specific types for testing purposes. Normally you would never know these specific types and normally you would not have such error messages. I saw this has led too more confusion in other tests as well, so please consider this subtlety, because we are not testing the normal rascal programs like this. —
Jurgen J. Vinju
CWI SWAT
INRIA Lille
UvA master software engineering
http://jurgen.vinju.org

On Tue, Dec 31, 2013 at 4:27 PM, Paul Klint notifications@github.com
wrote:

Closed #473.

Reply to this email directly or view it on GitHub:
#473

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

4 participants