Skip to content

Commit

Permalink
typechecker: Choose broader value type when typechecking a dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
0GreenClover0 authored and alimpfard committed Jul 21, 2024
1 parent ff500cd commit c1de5b6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions selfhost/typechecker.jakt
Original file line number Diff line number Diff line change
Expand Up @@ -10685,6 +10685,15 @@ struct Typechecker {
}
}

if value_hint.has_value() {
value_type_id = .choose_broader_type_id(
original_type_id: value_type_id
potential_type_id: value_hint!
generic_inferences: &mut .generic_inferences
span
)
}

if key_hint.has_value() {
key_type_id = .choose_broader_type_id(
original_type_id: key_type_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// Expect:
/// - output: "PASS\n"

class Base {}

class Derived : Base {}

fn func(anon a: [i64:Base]) {
println("PASS")
}

fn main() {
func([2:Derived()])
}

0 comments on commit c1de5b6

Please sign in to comment.