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

[BUG] parse_expr macro fails if one of the parsings have failed #513

Open
b1ek opened this issue Oct 15, 2024 · 1 comment
Open

[BUG] parse_expr macro fails if one of the parsings have failed #513

b1ek opened this issue Oct 15, 2024 · 1 comment
Labels
bug Something isn't working compiler

Comments

@b1ek
Copy link
Member

b1ek commented Oct 15, 2024

Describe the bug
see #504

To Reproduce
it is an internal compiler bug, which doesn't happen in normal amber use case.

let me explain:

there are multiple ExprType, and it parses the Expr with the parse_expr macro:

fn parse(&mut self, meta: &mut ParserMetadata) -> SyntaxResult {
let result = parse_expr!(meta, [
ternary @ TernOp => [ Ternary ],
range @ BinOp => [ Range ],
or @ BinOp => [ Or ],
and @ BinOp => [ And ],
equality @ BinOp => [ Eq, Neq ],
relation @ BinOp => [ Gt, Ge, Lt, Le ],
addition @ BinOp => [ Add, Sub ],
multiplication @ BinOp => [ Mul, Div, Modulo ],
types @ TypeOp => [ Is, Cast ],
unops @ UnOp => [ Neg, Not ],
literals @ Literal => [
// Literals
Parentheses, Bool, Number, Text,
Array, Null, Nameof, Status,
// Function invocation
FunctionInvocation, Command,
// Variable access
VariableGet
]
]);
*self = result;
Ok(())
}
}

and the parse_expr fails if one of the parsings have failed, as an example what happened in #504 - the VariableGet parsing failed, and it didn't get to try to parse Len.

Expected behavior
for it to parse all of them until at least one Ok

Additional context
its a rather sneaky issue because its hard to undestand what is the problem here. maybe i don't understand how it works, since i didnt even look at the macro source code - it looks like machine code to me.

i think @Ph0enixKM is literally the only person who actually understands how macros work, so please do comment

@b1ek b1ek added bug Something isn't working compiler labels Oct 15, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Oct 15, 2024
@b1ek
Copy link
Member Author

b1ek commented Oct 15, 2024

if i move it down it will fail

big image

image

but if i make it as it is in the PR it will work as expected

big image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler
Projects
None yet
Development

No branches or pull requests

1 participant