mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-01 03:38:55 +00:00
Merge pull request #7157 from aelobdog/fix-issue-7073-1
fix: expand_values panic on type expressions
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
11
tests/issues/test_issue_7073-1.odin
Normal file
11
tests/issues/test_issue_7073-1.odin
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user