mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-25 22:41:34 +00:00
Merge pull request #7415 from kalsprite/branch_location_addr
Fix compiler panic on a selector into `#branch_location`
This commit is contained in:
@@ -6546,6 +6546,11 @@ gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) {
|
||||
return lb_build_addr_from_entity(p, e, expr);
|
||||
case_end;
|
||||
|
||||
case_ast_node(bd, BasicDirective, expr);
|
||||
lbValue ptr = lb_address_from_load_or_generate_local(p, lb_build_expr(p, expr));
|
||||
return lb_addr(ptr);
|
||||
case_end;
|
||||
|
||||
case_ast_node(se, SelectorExpr, expr);
|
||||
Ast *sel_node = unparen_expr(se->selector);
|
||||
if (sel_node->kind == Ast_Ident) {
|
||||
|
||||
26
tests/internal/test_branch_location.odin
Normal file
26
tests/internal/test_branch_location.odin
Normal file
@@ -0,0 +1,26 @@
|
||||
package test_internal
|
||||
|
||||
import "core:testing"
|
||||
|
||||
@(private="file")
|
||||
returns_at :: proc(early: bool, got: ^i32) -> (expected: i32) {
|
||||
defer got^ = #branch_location.line
|
||||
|
||||
if early {
|
||||
return #line
|
||||
}
|
||||
|
||||
return #line
|
||||
}
|
||||
|
||||
// A selector on `#branch_location` reached `lb_build_addr`, which had no case for a directive
|
||||
@(test)
|
||||
branch_location_field_access :: proc(t: ^testing.T) {
|
||||
got: i32
|
||||
|
||||
expected := returns_at(true, &got)
|
||||
testing.expect_value(t, got, expected)
|
||||
|
||||
expected = returns_at(false, &got)
|
||||
testing.expect_value(t, got, expected)
|
||||
}
|
||||
Reference in New Issue
Block a user