Skip to content

Commit

Permalink
Fix type checking of HTML element references through a component.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdotdesign committed Sep 19, 2023
1 parent 872c8b6 commit e4af7b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions spec/examples/html_element
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,25 @@ component Main {
<div::base style="opacity:0;"/>
}
}
-------------------------------------------------------------------------------
enum Maybe(a) {
Nothing
Just(a)
}

component Test {
fun render : Html {
<div as test><{ "Hello" }></div>
}
}

component Main {
fun render : Html {
case test {
Maybe::Just(item) => { item.test "" }
Maybe::Nothing => ""
}

<Test as test/>
}
}
3 changes: 2 additions & 1 deletion src/type_checkers/access.cr
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ module Mint
memo[variable.value] = record.first
end
when Ast::HtmlElement
memo[variable.value] = variable
lookups[node.field] = {variable, component}
return Type.new("Maybe", [Type.new("Dom.Element")] of Checkable) if node.field.value == variable.value
end

memo
Expand Down

0 comments on commit e4af7b9

Please sign in to comment.