Fix bug when multiple $else clauses followed an $if #1824.

This commit is contained in:
Christoffer Lerno
2025-01-12 13:31:35 +01:00
parent 7a805340c5
commit f65ca07b62
3 changed files with 11 additions and 1 deletions

View File

@@ -31,6 +31,7 @@
- Handle bytes and string literals the same way in terms of zero termination.
- Function comments are stored and displayed with -P.
- Prevent `#hash` arguments from taking code that modifies ct variables. #1794
### Fixes
- Fix case trying to initialize a `char[*]*` from a String.
- Fix Map & HashMap `put_all_for_create` not copying all elements, causing `init_from_map` to create incomplete copy.
@@ -79,6 +80,7 @@
- Assert when partially initializing a constant struct containing a slice #1812.
- Assert concatenating constant slices #1805.
- Do not link "ld" on Linux with no libc.
- Fix bug when multiple `$else` clauses followed an `$if` #1824.
### Stdlib changes
- Increase BitWriter.write_bits limit up to 32 bits.

View File

@@ -1040,7 +1040,7 @@ static inline Ast *parse_ct_if_stmt(ParseContext *c)
if (!parse_ct_compound_stmt(c, &else_ast->ct_else_stmt)) return poisoned_ast;
ast->ct_if_stmt.elif = astid(else_ast);
}
advance_and_verify(c, TOKEN_CT_ENDIF);
CONSUME_OR_RET(TOKEN_CT_ENDIF, poisoned_ast);
RANGE_EXTEND_PREV(ast);
return ast;
}

View File

@@ -0,0 +1,8 @@
// Issue #1824
fn void main()
{
$if true:
$else
$else // #error: Expected '$endif'
$endif
}