Merge pull request #7415 from kalsprite/branch_location_addr

Fix compiler panic on a selector into `#branch_location`
This commit is contained in:
Jeroen van Rijn
2026-08-22 02:03:48 +02:00
committed by GitHub
2 changed files with 31 additions and 0 deletions

View File

@@ -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) {

View 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)
}