Check that integer literals are primitive types in patterns

This commit is contained in:
Nick Fitzgerald
2021-09-30 09:51:09 -07:00
committed by Chris Fallin
parent ce207ee953
commit d2bd07c246

View File

@@ -1034,6 +1034,16 @@ impl TermEnv {
return None;
}
};
if !tyenv.types[ty.index()].is_prim() {
tyenv.report_error(
pos,
format!(
"expected non-primitive type {}, but found integer literal '{}'",
tyenv.types[ty.index()].name(tyenv),
val,
),
);
}
Some((Pattern::ConstInt(ty, val), ty))
}
&ast::Pattern::ConstPrim { ref val, pos } => {