-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't workingrust-mismatchConfusing mismatch between Garble and RustConfusing mismatch between Garble and Rust
Description
#[test]
fn reject_redefine_bitonic_join() -> Result<(), Error> {
let prg = "
fn foo(r: u64) -> u64 { r }
fn foo(a: u8) -> u8 {
a
}
pub fn main(a: u8) -> u8 {
foo(a)
}
";
let e = scan(prg)?.parse()?.type_check();
let e = assert_single_type_error(e);
dbg!(&e);
Ok(())
}fails with
Expected an error, but found Ok(Program { const_deps: {}, const_defs: {}, struct_defs: {}, enum_defs: {}, fn_defs: {"foo": FnDef { is_pub: false, identifier: "foo", ty: Unsigned(U8), params: [ParamDef { mutability: Immutable, name: "a", ty: Unsigned(U8) }], body: [Stmt { inner: Expr(Expr { inner: Identifier("a"), meta: 4:4-4:5, ty: Unsigned(U8) }), meta: 4:4-4:5 }], meta: 1:27-5:1 }, "main": FnDef { is_pub: true, identifier: "main", ty: Unsigned(U8), params: [ParamDef { mutability: Immutable, name: "a", ty: Unsigned(U8) }], body: [Stmt { inner: Expr(Expr { inner: FnCall("foo", [Expr { inner: Identifier("a"), meta: 9:6-9:7, ty: Unsigned(U8) }]), meta: 9:2-9:8, ty: Unsigned(U8) }), meta: 9:2-9:8 }], meta: 5:1-10:1 }} })If we change the order of the foo definition the program fails to type-check because the u64 will be used in main which will result in an incompatible type. I'd argue that that a redefinition in the same scope should be disallowed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingrust-mismatchConfusing mismatch between Garble and RustConfusing mismatch between Garble and Rust