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

Ambiguity between syntax constructor sort and abstract data type sort in visit typecheck _not reported_ #1932

Open
jurgenvinju opened this issue Mar 27, 2024 · 0 comments
Assignees

Comments

@jurgenvinju
Copy link
Member

Describe the bug

import ParseTree;
import lang::rascal::\syntax::Rascal;

private Symbol removeConditionals(Symbol sym) = visit(sym) {
  case conditional(s, _) => s
};

This generates:

[INFO] Warnings and errors for lang/rascal/grammar/ConcreteSyntax.rsc
[ERROR] lang/rascal/grammar/ConcreteSyntax.rsc:068:007: A pattern of type Replacement cannot be replaced by Expression

The cause is:

syntax Replacement
	= unconditional: Expression replacementExpression 
	| conditional: Expression replacementExpression "when" {Expression ","}+ conditions ;

and

data Symbol // <19>
     = \conditional(Symbol symbol, set[Condition] conditions);

Both conditional constructors have two arguments, so they might indeed match the pattern. In this case a warning or error regarding the ambiguous constructor is expected:

Ambiguous constructor conditional could be either X or Y

But the type-checker currently forgets accidentally about the Symbol version.

I'm not sure if the visit is essential in this example. I think it does require an ambiguous constructor on the pattern side. I'm fixing the code in the standard library to avoid this issue for now.

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