elm-in-elm / compiler

Elm compiler written in Elm
https://elm-in-elm.github.io/compiler/
BSD 3-Clause "New" or "Revised" License
388 stars 24 forks source link

Parse error on record #129

Closed xarvh closed 3 years ago

xarvh commented 3 years ago

Elm.Compiler.parseModule produces a parse error on the following valid Elm code:

module Target exposing (..)

something =
    { a = 1
    , b = 2
    }

The error being:

    Err
        (ParseError
            (ParseProblem
                [ { col = 1
                  , contextStack = []
                  , problem = ExpectingModuleKeyword
                  , row = 1
                  }
                , { col = 1, contextStack = [], problem = ExpectingPortKeyword, row = 1 }
                , { col = 1, contextStack = [], problem = ExpectingEffectKeyword, row = 1 }
                ]
            )
        )

SSCCE:

module Main exposing (main)

import Elm.Compiler
import Html

code =
    """
module Target exposing (..)

something =
    { a = 1
    , b = 2
    }
"""

main =
    { filePath = "Target.elm"
    , sourceCode = code
    }
        |> Elm.Compiler.parseModule
        |> Debug.toString
        |> Html.text
Janiczek commented 3 years ago

Having this in the example-project/src/Main.elm:

module Main exposing (..)

main =
    { a = 1
    , b = 2
    }

and running make, this is the output I get on current elm-in-elm master:

Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
---------------------------
-- STARTING THE COMPILER --
---------------------------
Main.main: Value { expression = Record [{ body = Int 1, name = "a" },{ body = Int 2, name = "b" }], typeAnnotation = Nothing }
Compilation finished, writing output.
---------------------------
-- WRITING TO FS ----------
---------------------------
const Main$main = {a: 1, b: 2};

Which makes me think it works on the latest version, it just doesn't work in the version in the package.

@xarvh Does that help a little? Are you in a need of something elm-in-elm provides via the package? Should I create a release? (Again, there's a bunch of WIP stuff, we're still ways off from a properly working compiler)

xarvh commented 3 years ago

Thanks a lot @Janiczek, I think we'll be fine removing the package and checking out master. =)