Skip to content

Commit

Permalink
Typecheck Expressions - Fix missing integer literal ivar annotations …
Browse files Browse the repository at this point in the history
…on pattern types.

Fixes #318
  • Loading branch information
thepowersgang committed Sep 26, 2023
1 parent 417f293 commit 4c7e817
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions samples/test/mrustc-318.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::env;

fn main() {
let args: Vec<String> = env::args().collect();

match args.len() {
2 => {
match args[1].parse() {
Ok(42) => println!("branch ok(42)"),
_ => println!("branch _"),
}
},
_ => {
// code
}
}
}
4 changes: 2 additions & 2 deletions src/hir_typeck/expr_cs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2286,13 +2286,13 @@ void Context::handle_pattern(const Span& sp, ::HIR::Pattern& pat, const ::HIR::T
TU_MATCH_HDR( (pv), {)
TU_ARM(pv, Integer, ve) {
if( ve.type == ::HIR::CoreType::Str ) {
return ::HIR::TypeRef::new_infer(context.m_ivars.new_ivar(), ::HIR::InferClass::Integer);
return context.m_ivars.new_ivar_tr(::HIR::InferClass::Integer);
}
return ve.type;
}
TU_ARM(pv, Float, ve) {
if( ve.type == ::HIR::CoreType::Str ) {
return ::HIR::TypeRef::new_infer(context.m_ivars.new_ivar(), ::HIR::InferClass::Float);
return context.m_ivars.new_ivar_tr(::HIR::InferClass::Float);
}
return ve.type;
}
Expand Down

0 comments on commit 4c7e817

Please sign in to comment.