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 does not support keyword parameters in data declarations #456

Closed
PaulKlint opened this issue Dec 22, 2013 · 5 comments
Closed

TC does not support keyword parameters in data declarations #456

PaulKlint opened this issue Dec 22, 2013 · 5 comments

Comments

@PaulKlint
Copy link
Member

The type checker complains about the following:

data POINT1 = point1(int x, int y, int z = 3, list[str] colors = []);   

value main(list[value] args) =  point1(1,2);

gives

error("Name point1 is not in scope",|rascal:///experiments/Compiler/Examples/Tst.rsc|(149,6,<5,32>,<5,38>))
@mahills
Copy link
Member

mahills commented Dec 28, 2013

I'm currently working on adding this. A question: can constructor declarations re-provide common keyword parameters given at the datatype level, or do the keywords given on constructors need to be distinct from those given on data types?

@PaulKlint
Copy link
Member Author

@Anastassija can you answer this?

@mahills
Copy link
Member

mahills commented Dec 29, 2013

I'm currently working under the assumption (which may or may not be correct) that different common parameters can be given on different data declarations for the same datatype, as long as they are consistent (i.e., of the same type) in cases where the same keyword is repeated. I can tighten this up, but I'm not sure how tight we want to make this. We already don't allow keyword parameters on data declarations with no constructors, so we already have a case where different declarations can provide different common keyword parameters.

@mahills
Copy link
Member

mahills commented Dec 29, 2013

One obvious thing I could do is check to be sure that the same expression is given as a default for any occurrence of the common keyword parameter, but I'm not sure if this is helpful, and it may not be trivial, depending on how rich the expressions are that can be used as defaults (even if we allow variables, we would need to ensure that all occurrences of the variable are the same variable, so we can't just use a purely syntactic check).

@mahills
Copy link
Member

mahills commented Jan 7, 2014

This should now be working. There is one case we are having trouble with -- where the keyword parameters are separated from the others by a comma and where a structured type, using a [ character, is used, the concrete syntax match fails. That isn't directly related to this issue, though, so I'll close it.

@mahills mahills closed this as completed Jan 7, 2014
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