close
The Wayback Machine - https://web.archive.org/web/20220411045319/https://github.com/rome/tools/issues/1765
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

📎 Detect overlaping sub-uninos #1765

Open
MichaReiser opened this issue Nov 10, 2021 · 3 comments
Open

📎 Detect overlaping sub-uninos #1765

MichaReiser opened this issue Nov 10, 2021 · 3 comments
Labels
enhancement good first issue task tooling

Comments

@MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Nov 10, 2021

Description

#1745 introduced codegen support for unions over sub-unions. For example, we can now write JsExprOrSpread = JsExpr | JsSpread in our grammar and the codegen then knows that JsExprOrSpread can be any expression or a spread element.

The goal is to add a check to the codegen to fail if any two sub-unions of a union type are overlapping because it leads to disambiguity. For example, let's assume we have the following definition:

JsThisIsAnIssue = JsExprOrFunctionDeclaration | JsExprOrSpread
JsExprOrFunctionDeclaration = JsExpr | JsFunctionDeclaration
JsExprOrSpread = JsExpr | JsSpread

The sub-unions JsExprOrFunctionDeclaration and JsExprOrSpread are overlapping because both contain JsExpr.

The problem is that it's now unclear if an expression should be wrapped as a JsExprOrFunctionDeclaration or JsExprOrSpread.

You can trigger the code gen by running cargo xtask syntax in the project root.

@MichaReiser MichaReiser added enhancement good first issue task labels Nov 10, 2021
@ematipico
Copy link
Collaborator

@ematipico ematipico commented Nov 10, 2021

We should explain why in this example there's ambiguity. :)

I mean, I read JsExprOrFunctionDeclaration and JsExprOrSpread and I don't know where is the overlapping :) I can guess it by their name... because both nodes will contain Expr? If so, it's worth adding it to the example and maybe suggest what error message the code gen should return upon failing.

@daud9
Copy link

@daud9 daud9 commented Jan 5, 2022

Need to learn about this coding pls

@loginn
Copy link

@loginn loginn commented Apr 8, 2022

Hey I'd be down to try to work on this :)

@ematipico ematipico added the tooling label Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue task tooling
Projects
None yet
Development

No branches or pull requests

4 participants