diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-28 15:24:28 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-28 15:24:28 +0900 |
| commit | 1b208f7f0a3b7d6b72c2a431d9fcd6e18fe76f5d (patch) | |
| tree | 4902e2907f39cb0ae05439365e70d5628396a6fc /src/parse.c | |
| parent | 235969b792bf11e8b7927318cf01b5ef5705177b (diff) | |
| download | ducc-1b208f7f0a3b7d6b72c2a431d9fcd6e18fe76f5d.tar.gz ducc-1b208f7f0a3b7d6b72c2a431d9fcd6e18fe76f5d.tar.zst ducc-1b208f7f0a3b7d6b72c2a431d9fcd6e18fe76f5d.zip | |
feat: support using function as a value
Diffstat (limited to 'src/parse.c')
| -rw-r--r-- | src/parse.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/parse.c b/src/parse.c index dbbb61d..80c7aac 100644 --- a/src/parse.c +++ b/src/parse.c @@ -406,7 +406,14 @@ static AstNode* parse_primary_expr(Parser* p) { if (gvar_idx == -1) { int enum_member_idx = find_enum_member(p, name); if (enum_member_idx == -1) { - fatal_error("undefined variable: %s", name); + int func_idx = find_func(p, name); + if (func_idx == -1) { + fatal_error("undefined variable: %s", name); + } + AstNode* e = ast_new(AstNodeKind_func); + e->name = name; + e->ty = p->funcs.data[func_idx].ty; + return e; } int enum_idx = enum_member_idx / 1000; int n = enum_member_idx % 1000; |
