$eval now also works with @foo, #foo, $Foo and $foo parameters #2114.

This commit is contained in:
Christoffer Lerno
2025-06-06 01:23:23 +02:00
parent ef649050c4
commit 9baeca3a8e
8 changed files with 111 additions and 53 deletions

View File

@@ -2,7 +2,7 @@ import std::io;
fn void main()
{
$eval("foo()"); // #error: with $eval
$eval("foo()"); // #error: could not be resolved to a valid
}
fn void foo()
{

View File

@@ -0,0 +1,30 @@
// #target: macos-x64
module test;
macro @abc(#a)
{
$eval("#a") = 1;
}
fn void main()
{
int $foo = 1;
$eval("$foo") = 2;
$typefrom("int") x;
var $Type = double;
$typefrom("$Type") y;
$eval("@abc")(x);
x = 0;
$eval("test::@abc")(x);
}
/* #expect: test.ll
entry:
%x = alloca i32, align 4
%y = alloca double, align 8
store i32 0, ptr %x, align 4
store double 0.000000e+00, ptr %y, align 8
store i32 1, ptr %x, align 4
store i32 0, ptr %x, align 4
store i32 1, ptr %x, align 4
ret void
}