authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-10 16:33:43+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-10 16:44:15-05:00
log9cc7fb66bc00d54d8e4ff77cb6a0327488ceb59d
treed2ed86ee6d0a8a941e7ceab3ae18f6c081248ac9
parent84e98405de5f97101475000a95cd2293507e967d

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

1 files changed, 8 insertions(+), 4 deletions(-)

src/analyze.cpp+8-4
......@@ -3622,9 +3622,11 @@ void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source
36223622}
36233623
36243624void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) {
3625 Tld *tld = get_container_scope(g->compile_var_import)->decl_table.get(name);
3625 ScopeDecls *builtin_scope = get_container_scope(g->compile_var_import);
3626 Tld *tld = find_container_decl(g, builtin_scope, name);
3627 assert(tld != nullptr);
36263628 resolve_top_level_decl(g, tld, tld->source_node, false);
3627 assert(tld->id == TldIdVar);
3629 assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk);
36283630 TldVar *tld_var = (TldVar *)tld;
36293631 copy_const_val(tld_var->var->const_value, value);
36303632 tld_var->var->var_type = value->type;
......@@ -7588,9 +7590,11 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) {
75887590}
75897591
75907592ZigValue *get_builtin_value(CodeGen *codegen, const char *name) {
7591 Tld *tld = get_container_scope(codegen->compile_var_import)->decl_table.get(buf_create_from_str(name));
7593 ScopeDecls *builtin_scope = get_container_scope(codegen->compile_var_import);
7594 Tld *tld = find_container_decl(codegen, builtin_scope, buf_create_from_str(name));
7595 assert(tld != nullptr);
75927596 resolve_top_level_decl(codegen, tld, nullptr, false);
7593 assert(tld->id == TldIdVar);
7597 assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk);
75947598 TldVar *tld_var = (TldVar *)tld;
75957599 ZigValue *var_value = tld_var->var->const_value;
75967600 assert(var_value != nullptr);