Example program, the part with issue was directly copied from the examples.
defmodule Game.Counter do
use TermUI.Elm
alias TermUI.Event
alias TermUI.Layout.Constraint
def init(_opts), do: %{count: 0}
def event_to_msg(%Event.Key{key: "q"}, _state), do: {:msg, :quit}
def event_to_msg(_, _), do: :ignore
def update(:quit, state), do: {state, [:quit]}
def view(state) do
stack(:vertical, [
stack(:horizontal, [
text("Visible 1"),
text("Visible 2")
]),
stack(:horizontal, [ #<- issue here
{text("Not visible"), Constraint.length(15)},
{text("Also not visible"), Constraint.fill()}
]),
text("Also visible")
])
end
end
Run output
Visible 1Visible 2
Also visible
Elixir ls dialyzer output on the line with the comment
The function call will not succeed.
TermUI.Component.Helpers.stack(:horizontal, [
{%TermUI.Component.RenderNode{
:cells => nil,
:children => [],
:content => binary(),
:direction => nil,
:height => nil,
:style =>
nil
| %TermUI.Renderer.Style{
:attrs => %MapSet{:map => MapSet.internal(_)},
:bg => atom() | byte() | {byte(), byte(), byte()},
:fg => atom() | byte() | {byte(), byte(), byte()}
},
:type => :text,
:width => nil
},
%{
:__struct__ => TermUI.Layout.Constraint.Fill | TermUI.Layout.Constraint.Length,
:value => non_neg_integer()
}},
...
])
will never return since the 2nd arguments differ
from the success typing arguments:
(:horizontal | :vertical, [
%TermUI.Component.RenderNode{
:cells => nil | [map()],
:children => [map()],
:content => nil | binary(),
:direction => :horizontal | nil | :vertical,
:height => :auto | nil | non_neg_integer(),
:style =>
nil
| %TermUI.Renderer.Style{
:attrs => map(),
:bg => atom() | byte() | {_, _, _},
:fg => atom() | byte() | {_, _, _}
},
:type => :box | :cells | :empty | :stack | :text,
:width => :auto | nil | non_neg_integer()
}
])
Elixir
Erlang/OTP 28 [erts-16.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]
Elixir 1.19.4 (compiled with Erlang/OTP 28)
Example program, the part with issue was directly copied from the examples.
Run output
Elixir ls dialyzer output on the line with the comment
Elixir