Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRuntime error with tuples #201
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 31, 2015
Contributor
I think this is a compiler error that has to do with name shadowing. Note that the runtime error goes away if you change the code to this:
smap : (a -> b -> (a,b)) -> a -> List b -> (a, List b)
smap f a list = case list of
[] -> (a, [])
b :: bs ->
let (a',b') = f a b
(a'', list') = smap f a' bs
in
(a'', b' :: list)or to this:
smap : (a -> b -> (a,b)) -> a -> List b -> (a, List b)
smap f a list = case list of
[] -> (a, [])
b :: bs ->
let (a',b') = f a b
(a'', list') = smap f a' bs
in
(a'', b' :: list')Can you close this issue here, check whether a corresponding issue is already open at the elm-compiler repo, and if not, open an issue there?
|
I think this is a compiler error that has to do with name shadowing. Note that the runtime error goes away if you change the code to this: smap : (a -> b -> (a,b)) -> a -> List b -> (a, List b)
smap f a list = case list of
[] -> (a, [])
b :: bs ->
let (a',b') = f a b
(a'', list') = smap f a' bs
in
(a'', b' :: list)or to this: smap : (a -> b -> (a,b)) -> a -> List b -> (a, List b)
smap f a list = case list of
[] -> (a, [])
b :: bs ->
let (a',b') = f a b
(a'', list') = smap f a' bs
in
(a'', b' :: list')Can you close this issue here, check whether a corresponding issue is already open at the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 31, 2015
Member
When you reopen, do you mind also putting in the generated JS? I think that'd help a lot in figuring out exactly what went wrong.
|
When you reopen, do you mind also putting in the generated JS? I think that'd help a lot in figuring out exactly what went wrong. |
jvoigtlaender
referenced this issue
Sep 4, 2015
Closed
Shadowing causes Uncaught TypeError: Cannot read property 'ctor' of undefined #1045
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rtfeldman
Jan 2, 2016
Member
Cannot reproduce in 0.16.
I pasted this into try-elm:
import Html exposing (text)
main =
text ("Hello, World!" ++ toString (test))
smap : (a -> b -> (a,b)) -> a -> List b -> (a, List b)
smap f a list = case list of
[] -> (a, [])
b :: bs ->
let (a',b') = f a b
(a'', list) = smap f a' bs
in
(a'', b' :: list)
test = smap (,) 0 [0]...and the screen displayed:
Hello, World!(0,[0])
@evancz I think this may have been fixed by the codegen updates in 0.16.
|
Cannot reproduce in 0.16. I pasted this into try-elm: import Html exposing (text)
main =
text ("Hello, World!" ++ toString (test))
smap : (a -> b -> (a,b)) -> a -> List b -> (a, List b)
smap f a list = case list of
[] -> (a, [])
b :: bs ->
let (a',b') = f a b
(a'', list) = smap f a' bs
in
(a'', b' :: list)
test = smap (,) 0 [0]...and the screen displayed:
@evancz I think this may have been fixed by the codegen updates in 0.16. |
evancz
closed this
Jan 2, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Cool, thanks for following up on this! |
TheSeamau5 commentedMar 16, 2015
I am unable to pin down why this error happens but the failing code is surprisingly short:
which causes the following error: