Fix nested hash resolution for access identifiers. Fixes #789

This commit is contained in:
Christoffer Lerno
2023-06-20 17:05:13 +02:00
parent c3da240bc0
commit f9548cb213
3 changed files with 39 additions and 2 deletions

View File

@@ -2824,7 +2824,8 @@ RETRY:
{
Decl *decl = sema_resolve_symbol(context, child->hash_ident_expr.identifier, NULL, child->span);
if (!decl_ok(decl)) return NULL;
return sema_expr_resolve_access_child(context, decl->var.init_expr, missing);
Expr *expr = copy_expr_single(decl->var.init_expr);
return sema_expr_resolve_access_child(decl->var.hash_var.context, expr, missing);
}
case EXPR_CT_EVAL:
{

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.532"
#define COMPILER_VERSION "0.4.533"

View File

@@ -0,0 +1,36 @@
// #target: macos-x64
module test;
fn void main()
{
@foo(x);
}
struct Point { float x; float y; }
macro @foo(#x)
{
@bar(#x);
}
macro @bar(#x)
{
Point pt;
var z = pt.#x;
}
/* #expect: test.ll
define void @test.main() #0 {
entry:
%pt = alloca %Point, align 4
%z = alloca float, align 4
%0 = getelementptr inbounds %Point, ptr %pt, i32 0, i32 0
store float 0.000000e+00, ptr %0, align 4
%1 = getelementptr inbounds %Point, ptr %pt, i32 0, i32 1
store float 0.000000e+00, ptr %1, align 4
%2 = getelementptr inbounds %Point, ptr %pt, i32 0, i32 0
%3 = load float, ptr %2, align 4
store float %3, ptr %z, align 4
ret void
}