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

Variable names in parentheses can't be accessed #306

Closed
jarble opened this issue Jun 26, 2022 · 4 comments
Closed

Variable names in parentheses can't be accessed #306

jarble opened this issue Jun 26, 2022 · 4 comments

Comments

@jarble
Copy link

jarble commented Jun 26, 2022

Whenever I try to access a variable that is defined in a named expression, the output is undefined:

a = output:(a1:"parse" " " a2:"this") {return output.a1;}

When I parse the string "parse this" using this grammar, the parser returns "undefined" instead of "parse".

Is this due to a bug in the parser generator?

@hildjj
Copy link
Contributor

hildjj commented Jun 26, 2022

This works as designed, for the moment You want this:

a = output:(a1:"parse" " " a2:"this" { return {a1, a2}}) {return output.a1;}

Or:

a = output:(@"parse" " "this") {return output}

If we add #302, your code will work.

(Sorry if there are typos, I'm mobile at the moment)

@hildjj
Copy link
Contributor

hildjj commented Jun 30, 2022

I'm closing this as a dup of #302.

@hildjj hildjj closed this as completed Jun 30, 2022
@reverofevil
Copy link

This issue is the best evidence of how much less value there is in backwards compatibility compared to usability. Users generally expect automatic return values to work. (And I remember I was surprised it didn't too!)

@hildjj
Copy link
Contributor

hildjj commented Jul 1, 2022

Let's take discussion to #302, please. In particular, that's the place to argue for the no-@ syntax.

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

No branches or pull requests

3 participants