diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-01-10 16:33:43 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-01-10 16:44:15 -0500 |
| commit | 9cc7fb66bc00d54d8e4ff77cb6a0327488ceb59d (patch) | |
| tree | d2ed86ee6d0a8a941e7ceab3ae18f6c081248ac9 /src/analyze.cpp | |
| parent | 84e98405de5f97101475000a95cd2293507e967d (diff) | |
| download | zig-9cc7fb66bc00d54d8e4ff77cb6a0327488ceb59d.tar.gz zig-9cc7fb66bc00d54d8e4ff77cb6a0327488ceb59d.zip | |
Don't special-case `builtin` too much
Let's use the usual declaration-searching mechanism that resolves the
`usingnamespace` declarations on the go instead of directly peeking into
the symbol table.
Fixes #4134
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 7fd26afc84..2958dd8917 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3622,9 +3622,11 @@ void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source } void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) { - Tld *tld = get_container_scope(g->compile_var_import)->decl_table.get(name); + ScopeDecls *builtin_scope = get_container_scope(g->compile_var_import); + Tld *tld = find_container_decl(g, builtin_scope, name); + assert(tld != nullptr); resolve_top_level_decl(g, tld, tld->source_node, false); - assert(tld->id == TldIdVar); + assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk); TldVar *tld_var = (TldVar *)tld; copy_const_val(tld_var->var->const_value, value); tld_var->var->var_type = value->type; @@ -7588,9 +7590,11 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) { } ZigValue *get_builtin_value(CodeGen *codegen, const char *name) { - Tld *tld = get_container_scope(codegen->compile_var_import)->decl_table.get(buf_create_from_str(name)); + ScopeDecls *builtin_scope = get_container_scope(codegen->compile_var_import); + Tld *tld = find_container_decl(codegen, builtin_scope, buf_create_from_str(name)); + assert(tld != nullptr); resolve_top_level_decl(codegen, tld, nullptr, false); - assert(tld->id == TldIdVar); + assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk); TldVar *tld_var = (TldVar *)tld; ZigValue *var_value = tld_var->var->const_value; assert(var_value != nullptr); |
