on master help sign in
Merge pull request #1178 from elm-lang/pr/1157
cb0e9efEvan Czaplicki
src/Type/Unify.hs+21−8
@@ -241,10 +241,20 @@ unifyRigid context maybeSuper maybeName otherContent =
241 return ()
241 return ()
242
242
243 Var Flex otherMaybeSuper _ ->
243 Var Flex otherMaybeSuper _ ->
244− if maybeSuper == otherMaybeSuper then
244+ case (maybeSuper, otherMaybeSuper) of
245+ (_, Nothing) ->
245− merge context (Var Rigid maybeSuper maybeName)
246+ merge context (Var Rigid maybeSuper maybeName)
246− else
247+
248+ (Nothing, Just _) ->
249+ mismatch context (Just (badRigid maybeName))
250+
251+ (Just super, Just otherSuper) ->
252+ case combineSupers super otherSuper of
253+ Right newSuper | newSuper == otherSuper ->
254+ merge context otherContent
255+
256+ _ ->
247− mismatch context (Just (badRigid maybeName))
257+ mismatch context (Just (badRigid maybeName))
248
258
249 Var Rigid _ otherMaybeName ->
259 Var Rigid _ otherMaybeName ->
250 mismatch context $ Just $
260 mismatch context $ Just $
@@ -279,10 +289,13 @@ unifySuper context super otherContent =
279 mismatch context (Just (doubleBad (errorSuper super) (Error.Rigid maybeName)))
289 mismatch context (Just (doubleBad (errorSuper super) (Error.Rigid maybeName)))
280
290
281 Var Rigid (Just otherSuper) maybeName ->
291 Var Rigid (Just otherSuper) maybeName ->
282− if super == otherSuper then
292+ case combineSupers super otherSuper of
293+ Right newSuper | newSuper == super ->
283− merge context otherContent
294+ merge context otherContent
284− else
295+
296+ _ ->
297+ mismatch context $ Just $
285− mismatch context (Just (doubleBad (errorSuper super) (Error.Rigid maybeName)))
298+ doubleBad (errorSuper super) (Error.Rigid maybeName)
286
299
287 Var Flex Nothing _ ->
300 Var Flex Nothing _ ->
288 merge context (Var Flex (Just super) Nothing)
301 merge context (Var Flex (Just super) Nothing)
tests/test-files/good-expected-js/Soundness/SpecificAnnotationInt.elm.jsnew file+10
@@ -0,0 +1,10 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values) return _elm.Main.values;
6+ var _U = Elm.Native.Utils.make(_elm);
7+ var _op = {};
8+ var px = function (x) { return "test";};
9+ return _elm.Main.values = {_op: _op,px: px};
10+};
tests/test-files/good-expected-js/Soundness/SpecificAnnotationNumber.elm.jsnew file+10
@@ -0,0 +1,10 @@
1+Elm.Main = Elm.Main || {};
2+Elm.Main.make = function (_elm) {
3+ "use strict";
4+ _elm.Main = _elm.Main || {};
5+ if (_elm.Main.values) return _elm.Main.values;
6+ var _U = Elm.Native.Utils.make(_elm);
7+ var _op = {};
8+ var px = function (x) { return "test";};
9+ return _elm.Main.values = {_op: _op,px: px};
10+};
tests/test-files/good/Soundness/SpecificAnnotationInt.elmnew file+4
@@ -0,0 +1,4 @@
1+
2+px : Int -> String
3+px x =
4+ "test"
tests/test-files/good/Soundness/SpecificAnnotationNumber.elmnew file+4
@@ -0,0 +1,4 @@
1+
2+px : number -> String
3+px x =
4+ "test"