From 61c939059d37943a8f073ce988f02e9a712f5034 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 21 Jan 2026 00:52:18 +0100 Subject: [PATCH] `int? ?` was not correctly handled. #2786 --- releasenotes.md | 1 + src/compiler/parse_stmt.c | 6 ------ test/test_suite/statements/optional_with_question.c3 | 3 +++ 3 files changed, 4 insertions(+), 6 deletions(-) create mode 100644 test/test_suite/statements/optional_with_question.c3 diff --git a/releasenotes.md b/releasenotes.md index 59e1b2f79..be5745e4d 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -29,6 +29,7 @@ - Inferring the size of a slice with an inner inferred array using {} isn't detected as error #2783 - Bug in sysv abi when passing union in with floats #2784 - When a global const has invalid attributes, handling is incorrect, leading to a crash #2785. +- `int? ?` was not correctly handled. #2786 ### Fixes - Regression with npot vector in struct triggering an assert #2219. diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index ea39a43e5..b9f98c1c1 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -1015,12 +1015,6 @@ static inline Ast *parse_decl_or_expr_stmt(ParseContext *c) return parse_ct_type_assign_stmt(c); } ASSIGN_EXPR_OR_RET(Expr *expr, parse_expr(c), poisoned_ast); - // We might be parsing "int!" - // If so we need to unwrap this. - if (expr->expr_kind == EXPR_OPTIONAL && expr->inner_expr->expr_kind == EXPR_TYPEINFO) - { - UNREACHABLE - } if (expr->expr_kind == EXPR_TYPEINFO) { ASSIGN_AST_OR_RET(Ast *ast, parse_decl_stmt_after_type(c, expr->type_expr), poisoned_ast); diff --git a/test/test_suite/statements/optional_with_question.c3 b/test/test_suite/statements/optional_with_question.c3 new file mode 100644 index 000000000..ea8923cc7 --- /dev/null +++ b/test/test_suite/statements/optional_with_question.c3 @@ -0,0 +1,3 @@ +fn void main() +{ +char? ~ // #error: Expected a fault before '~'