Compiler error SSCCE - toggle commenting App/Login/Update line 35 Animate Animation.Msg
Based on the code provided at https://github.com/elm/compiler/issues/1796 but stripped down
The error only happens (for me) when compilation is done with --debug.
Also, the minimal example to reproduce this is:
module Main exposing (main)
import Animation
import Browser
import Html
type Msg
= LoginMsg Animation.Msg
main : Program () Int Msg
main =
Browser.element
{ init = \_ -> ( 0, Cmd.none )
, subscriptions = \_ -> Sub.none
, update = \_ m -> ( m, Cmd.none )
, view = \_ -> Html.text ""
}
with mdgriffith/elm-style-animation installed.
If I copy the elm-style-animation source code into the src folder of the SSCCE and add the elm/time and elm/svg dependencies (from elm-style-animation), the error goes away.
Experiencing the exact same issue as @pdamoc and @simonh1000 with the elm-form package (https://package.elm-lang.org/packages/etaque/elm-form/latest), and can confirm that moving the source code into the src folder resolves the problem.
Just for the record, I'm not using either of these and get the error (presumably from some other - sufficiently complex - import)
Also getting this error, but uncertain where it's coming from.
My imports include:
```{
"type": "application",
"source-directories": [
"src",
"src/Page"
],
"elm-version": "0.19.0",
"dependencies": {
"direct": {
"elm/browser": "1.0.0",
"elm/core": "1.0.0",
"elm/html": "1.0.0",
"elm/http": "1.0.0",
"elm/json": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"tiziano88/elm-protobuf": "3.0.0"
},
"indirect": {
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.0",
"jweir/elm-iso8601": "5.0.2"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
elm make src/Main.elm
Success! Compiled 10 modules.
elm: Map.!: given key is not an element in the map
CallStack (from HasCallStack):
error, called at ./Data/Map/Internal.hs:610:17 in containers-0.5.11.0-K2TDqgYtGUcKxAY1UqVZ3R:Data.Map.Internal
```
I get this error without the --debug flag and without the animation import.
Edit: I also think it's worth noting that my entire app uses explicit imports everywhere. Perhaps this could be contributing in some fashion?
another SSCCE that produces this error (extracted from a report on Slack #beginners)
module Main exposing (main)
import Browser
import Html exposing (Html, text)
type Msg
= Tag (Html Msg)
main : Program () Int Msg
main =
Browser.sandbox
{ init = 0
, view = \_ -> text ""
, update = \_ m -> m
}
Another sample code attached. (using slashmili/phoenix-socket)
The problem occurs only in debug build.
It disappears when I remove in Main.elm Channel.Msg from
ChannelMessage Channel.Msg
or (PhxMsg.Msg Msg) in Channel.elm
compiler-error.zip
Thanks for the SSCCEs, all!
What is the smallest example anyone's seen of reproducing this without --debug?
(So far it seems to be reproducible in smaller examples with --debug, but all the examples that reproduce it without --debug are a lot bigger. Maybe I'm missing one though!)
@rtfeldman From what I've seen from the bug reports the cases without --debug (mine included) are fixed by clearing the elm-stuff folder. Not sure if there are exceptions to that, but if there aren't then wouldn't this indicate a problem with a stale or missing package, and as such would make it difficult to reproduce consistently?
Definitely, but unfortunately bugs that are difficult to reproduce consistently are also difficult to fix. 馃槄
Incidentally the reason I'm asking is that the --debug one and the one without --debug seem to be unrelated.
(Evan tracked down the cause of the --debug one, and is currently evaluating different fixes based on their compile time performance characteristics.)
So if anyone can find a SSCCE that is consistently reproducible without --debug (presumably with "build it, then change this, then build again" since the bug seems to be related to caching given that deleting elm-stuff fixes it), that would be super helpful!
One thing that I did that was somewhat out of the ordinary was forked a elm package that didn't support 0.19 yet, upgraded it to 0.19, cloned that to my repo locally and included it with source-directories in elm.json. That was compiling, then later once the package author updated their package I deleted my local source-directories folder and installed the official package via elm install.
Perhaps it had something to do with that process, but I'm finding it very hard to replicate. Just thought I'd mention that in case anyone else has a somewhat similar experience, maybe it'll help track things down. Then again though. maybe it had nothing to do with that. Got to love bugs like this!
So if anyone can find a SSCCE that is consistently reproducible (presumably with "build it, then change this, then build again" since the bug seems to be related to caching given that deleting
elm-stufffixes it), that would be super helpful!
The case I uploaded above happens only in debug mode but doesn't go away by deleting elm-stuff. There are two places in the code where I can make the problem go away. Happened on macOS 10.13.6 with Elm 0.19.0 installed with ASDF.
@synalysis sorry, edited to clarify that I meant a SSCCE for the bug without --debug. All set on the --debug one already!
@synalysis sorry, edited to clarify that I meant a SSCCE for the bug without
--debug. All set on the--debugone already!
Great! :-) Just wanted to provide a reproducible case that doesn't go away with deletion of elm-stuff.
What is the procedure to get such a fix? I see no change in the public repository so far. Will this only be available with a 0.19.1 version? I don't want to put pressure on someone, it's just about deciding how to proceed with my development.
We've talked about a potential 0.19.1 (with complete backwards compatibility with 0.19.0), but no firm plans yet!
Do you have information on what causes the bug so we can at least avoid the issue until a fix is made?
Do you have information on what causes the bug so we can at least avoid the issue until a fix is made?
@hayesgm for me it was sufficient to download the sources of the lib I used and reference them directly in elm.json like this:
"source-directories": [
"src",
"extern/phoenix-socket-4.2.1/src"
],
@hayesgm We had the same problem, fixed it by moving the bad dependency (torreyatcitty/the-best-decimal in our case) to "indirect" in elm.json
@JasonJAyalaP Yup, for me, I did (in a project with my code in src/elm):
cd src/elm
git clone https://github.com/torreyatcitty/the-best-decimal.git
rm -r the-best-decimal/.git
Then I went into my elm.json, removed torreyatcitty/the-best-decimal, promoted "cmditch/elm-bigint": "1.0.1" to direct and added "src/the-best-decimal/src" to source-directories.
Happy to make the changes to fix the-best-decimal if we knew what the issue was.
I have the same problem, but in my case it was caused by the krisajenkins/remotedata package. Adding it directly to source-directories worked, but it's not really a long term solution.
For those running into this, using the --debug flag & failing then and only then, I was able to hack the Elm compiler to spit out Union tag names from Extract.hs (where the problem lies) to uncover which Msg's deep in my app were the problematic ones. If of interest, happy to share a Docker file to help you uncover the issue in your own codebase (although a 19.1 would be most welcome)
@aaronwhite i'd be interested in trying your Dockerfile. cheers!
@aaronwhite I'm definitely interested in trying it out
@aaronwhite I'd also be interested in trying it out! I just ran into the problem with --debug enabled.
@aaronwhite I'm also interested. I also have the problem with --debug enabled.
So not near my machine w/ the docker build, but looks like Evan is closing these issues to consolidate. Let me just sneak in some notes for him or others if interested:
the bug exists somewhere in Extract.hs (used for generating debug info), it鈥檚 beyond me to solve it, but if you instrument extractUnion鈥檚 map access w/ something along the lines of case I.toUnionInternals (unions ! traceShow (N.toString name) name) of the (new) Elm compiler will spit out problematic tag names as it goes, the last one you see is your issue (you may need to repeat this multiple times). (edited)
I'd like to add another SSCCE. Seems to be a problem when putting an Array within a union type. Changing Array to List in the example below does not trigger the error.
module Main exposing (..)
import Browser
import Array exposing (Array)
import Html exposing (Html, text)
main : Program () Model Msg
main = Browser.sandbox { init = model, view = view, update = update }
type alias Model = Int
model : Model
model = 0
type Msg = PerformAction (Array String)
update : Msg -> Model -> Model
update msg m =
case msg of
PerformAction _ ->
m
view : Model -> Html Msg
view m =
text (String.fromInt m)
Anything having to do with --debug causing problems for certain types should be fixed by changes made in the development version. Some details on the fix are available at https://github.com/elm/compiler/pull/1850#issuecomment-509327575
The next compiler release will be 0.19.1, and the fix will become available then (alongside with a bunch of other improvements!)
hello everyone
I am facing the same issue and I not sure how to tackle it. Just as a heads-up, sorry I cannot provide any useful information at this stage. I am on boarding to an existing application in which case it would be very useful to use the --debug flag.
I understand some people were able to come up with a workaround by either changing message types or downloading dependencies.
How would I find out what to tackle first?
Another approach would be to install the development version, I suppose. Is this described somewhere?
Many thanks in advance!
@flurin-conradin I would recommend getting the development version. You will need to download the binary for your system and then update the elm.json to use 0.19.1. See https://discourse.elm-lang.org/t/community-beta-for-elm-0-19-1/4102.
If you are using create-elm-app I have writtin instructions here: https://discourse.elm-lang.org/t/community-beta-for-elm-0-19-1/4102/26?u=franzskuffka
Most helpful comment
For those running into this, using the
--debugflag & failing then and only then, I was able to hack the Elm compiler to spit out Union tag names fromExtract.hs(where the problem lies) to uncover whichMsg's deep in my app were the problematic ones. If of interest, happy to share a Docker file to help you uncover the issue in your own codebase (although a 19.1 would be most welcome)