diff --git a/releasenotes.md b/releasenotes.md index ce242fe93..cd69f62bf 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -66,6 +66,7 @@ - Lambdas on the top level were not exported by default. #2428 - `has_tagof` on tagged lambdas returns false #2432 - Properly add "inlined at" for generic instantiation errors #2382. +- Inlining a const as an lvalue would take the wrong path and corrupt the expression node. ### Stdlib changes - Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`. diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 54663e4d6..c159924a1 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -11315,7 +11315,7 @@ RETRY: goto IDENT_CHECK; case EXPR_UNRESOLVED_IDENTIFIER: if (!sema_analyse_expr_dispatch(context, expr, CHECK_VALUE)) return false; - FALLTHROUGH; + goto RETRY; case EXPR_IDENTIFIER: IDENT_CHECK:; { diff --git a/test/test_suite/macros/hash_ident_folding.c3 b/test/test_suite/macros/hash_ident_folding.c3 new file mode 100644 index 000000000..978149b66 --- /dev/null +++ b/test/test_suite/macros/hash_ident_folding.c3 @@ -0,0 +1,21 @@ +module testi; + +macro @foo(#x) +{ + #x *= 2; // #error: You cannot assign to a constant expression +} + +attrdef @On_Start(x) = @tag("on_start", @foo(x)); + +fn void some() @On_Start(fn void(int a) { ; }) +{ +} + +fn int main() => main2(); + +macro main2() +{ + some.tagof("on_start")(1); + some(); + return 0; +} \ No newline at end of file