Skip to content

Commit e528bdb

Browse files
committed
Fix type checking of unboxing.
1 parent 997c244 commit e528bdb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/type_checkers/if.cr

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ module Mint
1616
else
1717
case expression = item.expression
1818
when Ast::Variable
19-
if Comparer.matches_any?(condition, [MAYBE, RESULT])
19+
type =
20+
if resolved = Comparer.compare(condition, MAYBE)
21+
resolved.parameters.first
22+
elsif resolved = Comparer.compare(condition, RESULT)
23+
resolved.parameters.last
24+
end
25+
26+
if type
2027
expression.unboxed = true
21-
cache[expression] = condition.parameters.first
28+
cache[expression] = type
2229
[{expression.value, cache[expression], expression}]
2330
end
2431
end

0 commit comments

Comments
 (0)