Skip to content

Commit

Permalink
Merge pull request #301 from savi-lang/fix/reachability-bug
Browse files Browse the repository at this point in the history
Fix compiler crash related to reachability of `<:` type expressions.
  • Loading branch information
jemc authored Apr 20, 2022
2 parents 8c5a48f + 2fa3716 commit 56706a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/core/Array.Spec.savi
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@
assert: ["foo", "bar", "baz"].includes("foo")
assert: ["foo", "bar", "baz"].includes("f").is_false

:it "can check for inclusion even of `non` modules by type id"
array Array(Any'non) = []
assert: array.includes(None).is_false

array.push(None)
assert: array.includes(None)

:it "replaces via a yield block the element at the given index, if it exists"
array Array(String) = ["foo", "bar", "baz"]

Expand Down
2 changes: 2 additions & 0 deletions src/savi/compiler/infer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ module Savi::Compiler::Infer
subtyping = ctx.subtyping.for_rf(rf)

@spans.each { |info, span|
next if info.is_a?(FixedTypeExpr)

next if subtyping.ignores_layer?(ctx, info.layer_index)

next if seen_spans.includes?(span)
Expand Down

0 comments on commit 56706a3

Please sign in to comment.