Fix Bool index in Bool.roc

This commit is contained in:
Richard Feldman 2025-10-09 13:28:02 -04:00
parent 5916742443
commit fe215a452d
No known key found for this signature in database
2 changed files with 8 additions and 3 deletions

View file

@ -46,14 +46,13 @@ pub fn main() !void {
const set_roc_source = try std.fs.cwd().readFileAlloc(gpa, "src/build/roc/Set.roc", 1024 * 1024);
defer gpa.free(set_roc_source);
// Compile Bool.roc without injecting Bool (it defines Bool itself)
// We still inject Result since Bool.roc might use it
// Compile Bool.roc without injecting anything (it's completely self-contained)
const bool_env = try compileModule(
gpa,
"Bool",
bool_roc_source,
&.{}, // No module dependencies
.{ .inject_bool = false, .inject_result = true },
.{ .inject_bool = false, .inject_result = false },
);
defer {
bool_env.deinit();

View file

@ -171,8 +171,14 @@ pub fn deinit(
self.scratch_free_vars.deinit(gpa);
}
/// Options for initializing the canonicalizer.
/// Controls which built-in types are injected into the module's scope.
pub const InitOptions = struct {
/// Whether to inject the Bool type declaration (`Bool := [True, False]`).
/// Set to false when compiling Bool.roc itself to avoid duplication.
inject_bool: bool = true,
/// Whether to inject the Result type declaration (`Result(ok, err) := [Ok(ok), Err(err)]`).
/// Set to false when compiling Result.roc itself (if it exists).
inject_result: bool = true,
};