This commit is contained in:
Richard Feldman 2025-09-27 07:57:29 -04:00
parent c146ff14ab
commit e46bb3e8d8
No known key found for this signature in database
4 changed files with 14 additions and 4 deletions

View file

@ -1367,6 +1367,12 @@ fn Unifier(comptime StoreTypeB: type) type {
}
self.merge(vars, vars.b.desc.content);
},
.frac_precision => |prec| {
// Promote decimal integers to the concrete fractional precision.
// Any fractional precision can represent integer literals, so no
// additional requirement checks are needed here.
self.merge(vars, Content{ .structure = .{ .num = .{ .frac_precision = prec } } });
},
.frac_unbound => |b_requirements| {
// When unifying num_unbound with frac_unbound, frac wins
self.merge(vars, Content{ .structure = .{ .num = .{ .frac_unbound = b_requirements } } });
@ -1500,6 +1506,10 @@ fn Unifier(comptime StoreTypeB: type) type {
return error.TypeMismatch;
}
},
.num_unbound => {
// Fractional precision wins when unified with decimal integer literals.
self.merge(vars, vars.a.desc.content);
},
.num_compact => |b_compact| {
switch (b_compact) {
.frac => |b_prec| {

View file

@ -118,14 +118,14 @@ const TestSummary = struct {
/// A test runner that can evaluate expect expressions in a module.
pub const TestRunner = struct {
allocator: Allocator,
env: *const ModuleEnv,
env: *ModuleEnv,
interpreter: Interpreter,
roc_ops: ?RocOps,
test_results: std.ArrayList(TestResult),
pub fn init(
allocator: std.mem.Allocator,
cir: *const ModuleEnv,
cir: *ModuleEnv,
) !TestRunner {
return TestRunner{
.allocator = allocator,

View file

@ -203,7 +203,7 @@ fn setupModuleEnv(shm: *SharedMemoryAllocator, roc_ops: *RocOps) ShimError!*Modu
/// Create and initialize interpreter with heap-allocated stable objects
fn createInterpreter(env_ptr: *ModuleEnv, roc_ops: *RocOps) ShimError!Interpreter {
const allocator = std.heap.page_allocator;
var interpreter = eval.Interpreter.init(allocator, env_ptr) catch {
const interpreter = eval.Interpreter.init(allocator, env_ptr) catch {
roc_ops.crash("INTERPRETER SHIM: Interpreter initialization failed");
return error.InterpreterSetupFailed;
};

View file

@ -1344,7 +1344,7 @@ fn writeCanCirResponse(response_buffer: []u8, data: CompilerStageData) ResponseW
fn writeEvaluateTestsResponse(response_buffer: []u8, data: CompilerStageData) ResponseWriteError!void {
// use arena for test evaluation
var env = data.module_env;
const env = data.module_env;
var local_arena = std.heap.ArenaAllocator.init(allocator);
defer local_arena.deinit();