Skip to content

Commit 7ba5ae7

Browse files
committed
Add function support to nameof keyword (amber-lang#673)
1 parent d3ceda3 commit 7ba5ae7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/modules/builtin/nameof.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,19 @@ impl SyntaxModule<ParserMetadata> for Nameof {
3737
Ok(())
3838
}
3939
None => {
40-
let tok = meta.get_current_token();
41-
error!(meta, tok, format!("Variable '{name}' not found"))
40+
match meta.get_fun_declaration(&name) {
41+
Some(fun_decl) => {
42+
self.name = format!("{}__{}_v0", &fun_decl.name, fun_decl.id);
43+
Ok(())
44+
}
45+
None => {
46+
let tok = meta.get_current_token();
47+
error!(meta, tok, format!("Variable or function '{name}' not found"))
48+
}
49+
}
4250
}
4351
}
52+
4453
}
4554
}
4655

0 commit comments

Comments
 (0)