diff --git a/src/check_expr.cpp b/src/check_expr.cpp index c8f07d7b5..eea6db2b4 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -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)) { diff --git a/tests/issues/run.bat b/tests/issues/run.bat index d2c5d88a1..8a85ba90a 100644 --- a/tests/issues/run.bat +++ b/tests/issues/run.bat @@ -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 diff --git a/tests/issues/run.sh b/tests/issues/run.sh index 49b60b86c..ce97a570a 100755 --- a/tests/issues/run.sh +++ b/tests/issues/run.sh @@ -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 diff --git a/tests/issues/test_issue_7073-1.odin b/tests/issues/test_issue_7073-1.odin new file mode 100644 index 000000000..49a7b01e3 --- /dev/null +++ b/tests/issues/test_issue_7073-1.odin @@ -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 +}