You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all! Found this today and I thought it could be added to #1373 as another constrained-type-variable-related bug.
The following type annotations should not type-check, but they do:
f : comparable ->Bool
f x = (x ++ x) < x
g : appendable ->Bool
g x = (x ++ x) < x
In the REPL, importing these from a module will lead to weird results (should I report this in elm-repl too?):
> f
<function>: a ->Bool> g
<function>: a ->Bool> f 0TypeError:Cannotread property 'ctor' ofundefined
In a compiled module, Elm will not allow you to call f or g on non-compappend arguments, but the error messages can be strange. For example, try pasting this into try-elm:
importHtml exposing (text)
f : appendable ->Bool
f xs = xs ++ xs < xs
g = f [text "Hello"]
(It's worth noting as well that trying to annotate f with compappend -> Bool doesn't work, because the compiler does not accept compappend as a constrained type variable within a type annotation. This also leads to a somewhat confusing compiler error, because the compiler suggests you replace your type annotation with compappend -> Bool -- what it already is.)
Hope this is helpful. Thanks for all your work, compiler team!
Edit to add (thanks, process-bot!): I'm using Elm 0.17.0 on Mac OS X El Capitan. try-elm running in Safari
The text was updated successfully, but these errors were encountered:
The new combineRigidSupers function makes sure that the rigid variable
always wins and that the rigid variable is a subset of the flex
variable.
There was also a bug in unifyRigid where the rigid variable would not
win! The flex one would win. This accounted for some fraction of the
bugs as well.
I also try to avoid allocating new rigid content in unifyRigid to maybe
make things a bit faster.
Fixes#1268Fixes#1270Fixes#1281Fixes#1316Fixes#1422Fixes#1581
With your first comparable example, the error with the latest build is:
-- TYPE MISMATCH ----------------------------------------------
The left argument of (<) is causing a type mismatch.
135| g x = (x ++ x) < x
^^^^^^
(<) is expecting the left argument to be a:
comparable
But the left argument is:
appendable
Hint: Your type annotation uses type variable `appendable` which means any type
of value can flow through. Your code is saying it CANNOT be anything though!
Maybe change your type annotation to be more specific? Maybe the code has a
problem? More at:
<https://github.com/elm-lang/elm-compiler/blob/0.19.0/hints/type-annotations.md>
With the appendable example, this is the error:
- TYPE MISMATCH ------------------------------------------
The left argument of (<) is causing a type mismatch.
132| f xs = xs ++ xs < xs
^^^^^^^^
(<) is expecting the left argument to be a:
comparable
But the left argument is:
appendable
Hint: Your type annotation uses type variable `appendable` which means any type
of value can flow through. Your code is saying it CANNOT be anything though!
Maybe change your type annotation to be more specific? Maybe the code has a
problem? More at:
<https://github.com/elm-lang/elm-compiler/blob/0.19.0/hints/type-annotations.md>
The hints are messed up right now, so I am working on fixing those at the moment!
Hi all! Found this today and I thought it could be added to #1373 as another constrained-type-variable-related bug.
The following type annotations should not type-check, but they do:
In the REPL, importing these from a module will lead to weird results (should I report this in elm-repl too?):
In a compiled module, Elm will not allow you to call
f
org
on non-compappend arguments, but the error messages can be strange. For example, try pasting this into try-elm:(It's worth noting as well that trying to annotate
f
withcompappend -> Bool
doesn't work, because the compiler does not acceptcompappend
as a constrained type variable within a type annotation. This also leads to a somewhat confusing compiler error, because the compiler suggests you replace your type annotation withcompappend -> Bool
-- what it already is.)Hope this is helpful. Thanks for all your work, compiler team!
Edit to add (thanks, process-bot!): I'm using Elm 0.17.0 on Mac OS X El Capitan. try-elm running in Safari
The text was updated successfully, but these errors were encountered: