mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-08 13:51:37 -04:00
This commit is contained in:
4 files changed
+29
-1
No files matched your search
+3
-1
@@ -9527,7 +9527,9 @@ gb_internal bool check_is_operand_compound_lit_constant(CheckerContext *c, Opera
|
||||
return true;
|
||||
}
|
||||
if (expr->kind == Ast_ProcLit) {
|
||||
add_type_and_value(c, expr, Addressing_Constant, type_of_expr(expr), exact_value_procedure(expr));
|
||||
ExactValue value = exact_value_procedure(expr);
|
||||
value.variant_type = o->value.variant_type;
|
||||
add_type_and_value(c, expr, Addressing_Constant, type_of_expr(expr), value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ clang -c ..\test_issue_sysv_abi.c -o test_issue_sysv_abi_c.o || exit /b
|
||||
..\..\..\odin test ..\test_issue_swizzle_multi_assign.odin %COMMON% || exit /b
|
||||
..\..\..\odin run ..\test_issue_7562.odin %COMMON% -no-crt -no-thread-local || exit /b
|
||||
..\..\..\odin run ..\test_issue_7562.odin %COMMON% -no-crt -no-thread-local -o:speed || exit /b
|
||||
..\..\..\odin run ..\test_issue_7596.odin %COMMON% || exit /b
|
||||
|
||||
@echo off
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ $ODIN test ../test_issue_7008.odin $COMMON
|
||||
$ODIN check ../test_issue_7012.odin -no-entry-point $COMMON_CHECK
|
||||
$ODIN build ../test_issue_7037.odin $COMMON -o:none
|
||||
$ODIN run ../test_issue_7564.odin $COMMON
|
||||
$ODIN run ../test_issue_7596.odin $COMMON
|
||||
$ODIN test ../test_issue_7421.odin $COMMON
|
||||
if [[ $($ODIN check ../test_issue_7421_tagged_duplicate.odin $COMMON_CHECK 2>&1 >/dev/null | grep -c "Error: Duplicate case") -eq 1 ]]; then
|
||||
echo "SUCCESSFUL 1/1"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Tests issue #7596 and #7511: a procedure literal converted to a union variant inside a
|
||||
// compound literal crashed the backend with `value_type != nullptr`.
|
||||
// https://github.com/odin-lang/Odin/issues/7596
|
||||
package test_issues
|
||||
|
||||
P :: proc() -> int
|
||||
U :: union {P, int}
|
||||
S :: struct {
|
||||
u: U,
|
||||
m: Maybe(P),
|
||||
}
|
||||
|
||||
global_slice := []U{proc() -> int { return 1 }, 2}
|
||||
global_struct := S{u = proc() -> int { return 3 }, m = proc() -> int { return 4 }}
|
||||
|
||||
main :: proc() {
|
||||
local := [1]U{proc() -> int { return 5 }}
|
||||
|
||||
assert(global_slice[0].(P)() == 1)
|
||||
assert(global_slice[1].(int) == 2)
|
||||
assert(global_struct.u.(P)() == 3)
|
||||
assert(global_struct.m.?() == 4)
|
||||
assert(local[0].(P)() == 5)
|
||||
}
|
||||
Reference in new issue
Block a user