fix: expand_values panic on type expressions

This commit is contained in:
aelobdog
2026-07-29 23:57:25 +05:30
parent adb351f551
commit d8eb6e0481
4 changed files with 24 additions and 0 deletions

View File

@@ -2996,6 +2996,11 @@ gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *
if (!o->type) {
return;
}
if (o->mode == Addressing_Type) {
gbString type_str = type_to_string(o->type);
error(node, "Cannot apply '**' to a type '%s', the operand must be a value of struct or array type", type_str);
gb_string_free(type_str);
}
Type *type = base_type(o->type);
if (!is_type_struct(type) && !is_type_array(type)) {

View File

@@ -40,6 +40,7 @@ set COMMON=-define:ODIN_TEST_FANCY=false -file -vet -strict-style -ignore-unused
..\..\..\odin check ..\test_issue_6874.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "1" || exit /b
..\..\..\odin check ..\test_issue_6979.odin -no-entry-point %COMMON% || exit /b
..\..\..\odin build ..\test_issue_7037.odin %COMMON% -o:none || exit /b
..\..\..\odin build ..\test_issue_7073-1.odin %COMMON% 2>&1 | find /c "Error:" | findstr /x "2" || exit /b
@echo off

View File

@@ -90,6 +90,13 @@ else
exit 1
fi
if [[ $($ODIN build ../test_issue_7073-1.odin $COMMON 2>&1 >/dev/null | grep -c "Error:") -eq 2 ]] ; then
echo "SUCCESSFUL 1/1"
else
echo "SUCCESSFUL 0/1"
exit 1
fi
clang -c ../test_issue_7010.c -o test_issue_7010_c.o
$ODIN test ../test_issue_7010.odin $COMMON

View File

@@ -0,0 +1,11 @@
// Tests issue #7073-part 1 https://github.com/odin-lang/Odin/issues/7073
package test_issues
main :: proc() {
arr := [2]int{10, 20}
_, _ = **arr // ok: array value
_, _ = **struct{x, y: int}{} // ok: struct value
_, _ = **[2]int // error: array type
_, _ = **struct{x, y: int} // error: struct type
}