When I try to compile this:

module Model exposing (..)

type Account
    = Account
        { uuid : String
        , username : Maybe String
        , password : Maybe String
        , root : Maybe Bool
        , id : Maybe String
        }




accountEncoder : Account -> Encode.Value
accountEncoder (Account model) =
    [ Just ( "uuid", Encode.string model.uuid )
    , Maybe.map (\username -> ( "username", Encode.string username )) model.
username
    , Maybe.map (\password -> ( "password", Encode.string password )) model.
password
    , Maybe.map (\root -> ( "root", Encode.bool root )) model.root
    , Maybe.map (\id -> ( "id", Encode.string id )) model.id
    ]
        |> catMaybes
        |> Encode.object



The compiler is somehow blind to the 'uuid' field being there:


-- TYPE MISMATCH --------------------------------- src/auth-client/elm/Model
.elm


`model` does not have a field named `uuid`.


176|     [ Just ( "uuid", Encode.string model.uuid )
                                        ^^^^^^^^^^
The type of `model` is:


    { id : Maybe String
    , password : Maybe String
    , roles : Maybe (List Role)
    , root : Maybe Bool
    , salt : Maybe String
    , username : Maybe String
    }




Which does not contain a field named `uuid`.



Erm.. what?

Interestingly, if I clear out 'elm-stuff' and try again, it fails but with 
different errors relating to other modules, some of which depend on this 
one. I don't get this error, but I do get an error in the Account.Service 
module which depends on this Model module saying that some of its code 
tries to create Accounts without uuids.

I just added the 'uuid' field, and the modules that consume this one do not 
yet have it in their code. My hypothesis is that the later modules are 
compiling some of the way, some information from that is being written to 
disk, and on the next compilation run that information is found to conflict 
with the Account type and the compiler comes out with this confusing error 
message. I see .elmi and .elmi files under 'elm-stuff' for the 
Account.Service module which depends on this one.

Perhaps if the compiler fails to compile a module it should do so more 
atomically, and not output a .elmi and .elmo files?
Also, getting different errors on two consecutive compiler runs is not 
idempotent behaviour.

Has anyone seen an error like this before? I don't see it in the github 
elm-compiler issues, so I though I might try and put together an SSCCE for 
it. Which I may manage to do, if my hypothese

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to