Open ASnow opened 1 month ago
Can you share a minimal reproducible example that causes this error?
Sorry. It took times to find exception point.
alias DslReplaceCondsFn = -> Bool
alias DslReplaceConds = Array(DslReplaceConds) | DslReplaceCondsFn
def _replace_map(cond : DslReplaceConds) : DslReplaceCondsFn
if cond.is_a?(Array)
cond_fns = cond.map { |x| _replace_map(x) }
->() { (cond_fns.all? { |fn| fn.call }) } # problem is here if write "? true : false " problem wil be fixed
else
->() { false }
end
end
_replace_map([-> () { true }, -> () { false }])
You could also write -> : Bool { cond_fns.all? { |fn| fn.call } }
, since it looks like the compiler had issues inferring that return type.
Reduction: (note that recursive types are not needed here, only a recursive def)
class Foo
@x = uninitialized -> Bool
end
def foo(cond) : -> Bool
if cond.is_a?(Foo)
-> { foo(cond.@x).call }
else
cond
end
end
foo(Foo.new)
Bug Report
In docker image https://hub.docker.com/layers/crystallang/crystal/1.12-alpine/images/sha256-297e82182800ff101755a2a26de747d6654eae3b487eb108aeac3299f181408d?context=explore