mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Merge pull request #2552 from jcmoyer/fix-2466
Use compound literal storage for ValueDecl lvals
This commit is contained in:
@@ -2463,6 +2463,7 @@ gb_internal void lb_build_stmt(lbProcedure *p, Ast *node) {
|
|||||||
lb_add_entity(p->module, e, val);
|
lb_add_entity(p->module, e, val);
|
||||||
lb_add_debug_local_variable(p, val.value, e->type, e->token);
|
lb_add_debug_local_variable(p, val.value, e->type, e->token);
|
||||||
lvals_preused[lval_index] = true;
|
lvals_preused[lval_index] = true;
|
||||||
|
lvals[lval_index] = *comp_lit_addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ set COMMON=-collection:tests=..\..
|
|||||||
..\..\..\odin test ..\test_issue_2056.odin %COMMON% -file || exit /b
|
..\..\..\odin test ..\test_issue_2056.odin %COMMON% -file || exit /b
|
||||||
..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file || exit /b
|
..\..\..\odin test ..\test_issue_2087.odin %COMMON% -file || exit /b
|
||||||
..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug || exit /b
|
..\..\..\odin build ..\test_issue_2113.odin %COMMON% -file -debug || exit /b
|
||||||
|
..\..\..\odin test ..\test_issue_2466.odin %COMMON% -file || exit /b
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ $ODIN test ../test_issue_1592.odin $COMMON -file
|
|||||||
$ODIN test ../test_issue_2056.odin $COMMON -file
|
$ODIN test ../test_issue_2056.odin $COMMON -file
|
||||||
$ODIN test ../test_issue_2087.odin $COMMON -file
|
$ODIN test ../test_issue_2087.odin $COMMON -file
|
||||||
$ODIN build ../test_issue_2113.odin $COMMON -file -debug
|
$ODIN build ../test_issue_2113.odin $COMMON -file -debug
|
||||||
|
$ODIN test ../test_issue_2466.odin $COMMON -file
|
||||||
|
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// Tests issue #2466 https://github.com/odin-lang/Odin/issues/2466
|
||||||
|
package test_issues
|
||||||
|
|
||||||
|
import "core:fmt"
|
||||||
|
import "core:testing"
|
||||||
|
|
||||||
|
Bug :: struct {
|
||||||
|
val: int,
|
||||||
|
arr: []int,
|
||||||
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
test_compound_literal_local_reuse :: proc(t: ^testing.T) {
|
||||||
|
v: int = 123
|
||||||
|
bug := Bug {
|
||||||
|
val = v,
|
||||||
|
arr = {42},
|
||||||
|
}
|
||||||
|
testing.expect(t, bug.val == 123, fmt.tprintf("expected 123, found %d", bug.val))
|
||||||
|
testing.expect(t, bug.arr[0] == 42, fmt.tprintf("expected 42, found %d", bug.arr[0]))
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user