mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Sync prod and tests more
This commit is contained in:
parent
13468e736c
commit
b10d5e806b
2 changed files with 16 additions and 43 deletions
|
|
@ -194,30 +194,14 @@ pub fn initWithImport(module_name: []const u8, source: []const u8, other_module_
|
|||
const other_module_ident = try module_env.insertIdent(base.Ident.for_text(other_module_name));
|
||||
try module_envs.put(other_module_ident, .{ .env = other_test_env.module_env });
|
||||
|
||||
// Add Bool, Result, Dict, and Set to module_envs for auto-importing
|
||||
// They all point to the same Builtin module env with different statement indices
|
||||
// Note: Str is NOT added because it's a primitive builtin type that's handled
|
||||
// specially in Can.zig line 5667 - it should never go through module_envs
|
||||
const bool_ident = try module_env.insertIdent(base.Ident.for_text("Bool"));
|
||||
const result_ident = try module_env.insertIdent(base.Ident.for_text("Result"));
|
||||
const dict_ident = try module_env.insertIdent(base.Ident.for_text("Dict"));
|
||||
const set_ident = try module_env.insertIdent(base.Ident.for_text("Set"));
|
||||
try module_envs.put(bool_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = builtin_indices.bool_type,
|
||||
});
|
||||
try module_envs.put(result_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = builtin_indices.result_type,
|
||||
});
|
||||
try module_envs.put(dict_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = builtin_indices.dict_type,
|
||||
});
|
||||
try module_envs.put(set_ident, .{
|
||||
.env = builtin_env,
|
||||
.statement_idx = builtin_indices.set_type,
|
||||
});
|
||||
// Populate module_envs with Bool, Result, Dict, Set using shared function
|
||||
// This ensures production and tests use identical logic
|
||||
try Can.populateModuleEnvs(
|
||||
&module_envs,
|
||||
module_env,
|
||||
builtin_env,
|
||||
builtin_indices,
|
||||
);
|
||||
|
||||
// Parse the AST
|
||||
parse_ast.* = try parse.parse(&module_env.common, gpa);
|
||||
|
|
|
|||
|
|
@ -1375,25 +1375,14 @@ pub fn setupSharedMemoryWithModuleEnv(allocs: *Allocators, roc_file_path: []cons
|
|||
var module_envs_map = std.AutoHashMap(base.Ident.Idx, Can.AutoImportedType).init(allocs.gpa);
|
||||
defer module_envs_map.deinit();
|
||||
|
||||
// Add Bool, Result, and Str to the map, all pointing to the Builtin module with pre-computed statement indices
|
||||
const builtin_indices = builtin_modules.builtin_indices;
|
||||
const bool_ident = try env.common.insertIdent(allocs.gpa, base.Ident.for_text("Bool"));
|
||||
try module_envs_map.put(bool_ident, .{
|
||||
.env = builtin_modules.builtin_module.env,
|
||||
.statement_idx = builtin_indices.bool_type,
|
||||
});
|
||||
|
||||
const result_ident = try env.common.insertIdent(allocs.gpa, base.Ident.for_text("Result"));
|
||||
try module_envs_map.put(result_ident, .{
|
||||
.env = builtin_modules.builtin_module.env,
|
||||
.statement_idx = builtin_indices.result_type,
|
||||
});
|
||||
|
||||
const str_ident = try env.common.insertIdent(allocs.gpa, base.Ident.for_text("Str"));
|
||||
try module_envs_map.put(str_ident, .{
|
||||
.env = builtin_modules.builtin_module.env,
|
||||
.statement_idx = builtin_indices.str_type,
|
||||
});
|
||||
// Populate module_envs with Bool, Result, Dict, Set using shared function
|
||||
// This ensures production and tests use identical logic
|
||||
try Can.populateModuleEnvs(
|
||||
&module_envs_map,
|
||||
&env,
|
||||
builtin_modules.builtin_module.env,
|
||||
builtin_modules.builtin_indices,
|
||||
);
|
||||
|
||||
// Create canonicalizer with module_envs
|
||||
var canonicalizer = try Can.init(&env, &parse_ast, &module_envs_map);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue