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

parse(#Exp, "2+3") example doesn't work #1423

Closed
Pytheas01 opened this issue May 22, 2020 · 6 comments
Closed

parse(#Exp, "2+3") example doesn't work #1423

Pytheas01 opened this issue May 22, 2020 · 6 comments
Labels

Comments

@Pytheas01
Copy link

Pytheas01 commented May 22, 2020

Describe the bug

the parse(#Exp, "2+3") statement causes a CallFailed error.

To Reproduce

rascal>import demo::lang::Exp::Concrete::NoLayout::Syntax;
ok
rascal>import ParseTree;
ok
rascal>parse(#Exp, "2+3");

causes

rascal>parse(#Exp, "2+3");
|prompt:///|(12,5,<1,12>,<1,17>): CallFailed(
  |prompt:///|(12,5,<1,12>,<1,17>),
  [type(
      adt(
        "Exp",
        []),
      (adt(
          "Exp",
          []):choice(
          adt(
            "Exp",
            []),
          {
            cons(
              label(
                "add",
                adt(
                  "Exp",
                  [])),...

Expected behavior

sort("Exp"): 2+3

... as per the documentation

Desktop (please complete the following information):
Eclispse 2020.03 using 2020-May-13 version of Rascal update.

@Pytheas01 Pytheas01 added the bug label May 22, 2020
@Pytheas01
Copy link
Author

Pytheas01 commented May 23, 2020

This morning, I've managed to make the example work, as follows:

  • right-click on project and select "Rascal Console"
  • import Concrete::NoLayout::Eval
  • import Concrete::NoLayout::Syntax
  • import ParseTree
    Only then can you type eval(parse(#Exp, "2+2")) at the prompt.
    I wonder why, after importing the Eval module, you have to import the Syntax and ParseTree modules again?

@jurgenvinju
Copy link
Member

Thanks for the report!

The issue is caused by the two different versions of Exp both in scope in the console. The current interpreter does not report the ambiguity and picks the first it can find for #Exp. In your case that was the data version and so there was no definition for parse to match.

The upcoming statically checked version of Rascal will warn about this and force a more qualified name.

Your workaround works accidentally; caused by the same bug: now you have the syntax version of Exp being resolved for #Exp and it goes well.

The best way to work with this for now is to separate scopes that import the concrete syntax from the scopes that use the abstract syntax. And thanks for the patience while we work on the Compiler-based REPL!

@jurgenvinju
Copy link
Member

Thanks for the diagnosis in Slack @tvdstorm

@jurgenvinju
Copy link
Member

Does this analysis help you @PHIROC ?

Note to self: change the instructions in the documentation to avoid this pitfall.

@Pytheas01
Copy link
Author

Pytheas01 commented May 24, 2020 via email

@jurgenvinju
Copy link
Member

This will be fixed by #1835

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

No branches or pull requests

2 participants