M src/backend/rust.rs +2 -2
@@ 186,7 186,7 @@ fn compile_decl(w: &mut impl Write, decl
let nstr = mangle_name(&*INT.fetch(*name));
let sstr = compile_fn_signature(signature);
let bstr = compile_exprs(body, ";\n", tck);
- writeln!(w, "pub fn {}{} {{\n{}\n}}\n", nstr, sstr, bstr)
+ writeln!(w, "pub const fn {}{} {{\n{}\n}}\n", nstr, sstr, bstr)
}
hir::Decl::Const {
name,
@@ 423,7 423,7 @@ fn compile_expr(expr: &hir::ExprNode, tc
E::TupleCtor { body } if body.len() == 0 => String::from(" ()\n"),
E::TupleCtor { body } => {
let contents = compile_exprs(body, ",", tck);
- format!("({})", contents)
+ format!("({},)", contents)
}
// Just becomes a function call.
// TODO someday: Make an explicit turbofish if necessary?
M src/passes.rs +0 -2
@@ 35,8 35,6 @@ pub fn run_typechecked_passes(ir: Ir, tc
let res = passes.iter().fold(ir, |prev_ir, f| f(prev_ir, tck));
println!();
println!("{}", res);
- // let passes: &[Pass] = &[lambda_lift];
- // passes.iter().fold(res, |prev_ir, f| f(prev_ir))
res
}
M tests/programs/test_module1.gt +8 -5
@@ 1,5 1,8 @@
-- Compile:
-- status: success
+-- Run:
+-- status: success
+-- stdout: 3
-- A hasher that only accepts basic integers and always returns an
-- integer. Implements a particular hash algorithm, with optional
@@ 9,15 12,15 @@
--
-- No associated types either, so we just make it a type param for now,
-- which surprisingly appears to work.
-type Hasher(@Self, @Out) = struct
- write: fn(@Self, I32) @Self,
- finish: fn(@Self) @Out,
+type Hasher(@Selff, @Out) = struct
+ write: fn(@Selff, I32) @Selff,
+ finish: fn(@Selff) @Out,
end
type DumbHashState = I32
-fn main() I32 =
+fn main() {} =
let dumbhasher Hasher(DumbHashState, I32) = Hasher {
.write = fn(s DumbHashState, i I32) DumbHashState = DumbHashState(i) end,
.finish = fn(s DumbHashState) I32 = 3 end
@@ 25,5 28,5 @@ fn main() I32 =
let hash_state = DumbHashState(1)
let updated_state = dumbhasher$.write(hash_state, 12)
let hash = dumbhasher$.finish(updated_state)
- hash
+ __println(hash)
end
M tests/programs/test_module2.gt +1 -2
@@ 3,8 3,7 @@
--
-- Run:
-- status: success
--- stdout:
--- 3
+-- stdout: 3
-- Dummy type
type String = I32