koka-lang / koka

Koka language compiler and interpreter

Home Page:http://koka-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build error on latest versions

chtenb opened this issue · comments

I wanted to compile and try the dev branch containing several fixes I'm interested in, but I get compile errors.

> stack update
(....)
> stack build --fast                                                                                                                                                                                          01/18/2024 09:37:16 PM
FloatingHex> configure
FloatingHex> Warning: FloatingHex.cabal:19:29: Packages with 'cabal-version: 1.12' or later
FloatingHex> should specify a specific version of the Cabal spec of the form
FloatingHex> 'cabal-version: x.y'. Use 'cabal-version: 1.14'.
FloatingHex> Configuring FloatingHex-0.5...
FloatingHex> build
FloatingHex> Preprocessing library for FloatingHex-0.5..
FloatingHex> Building library for FloatingHex-0.5..
FloatingHex> [1 of 1] Compiling Data.Numbers.FloatingHex
FloatingHex> copy/register
FloatingHex> Installing library in C:\sr\snapshots\27117814\lib\x86_64-windows-ghc-9.4.8\FloatingHex-0.5-AchJjivCpIPAS2cUp2htB
FloatingHex> Registering library for FloatingHex-0.5..
koka       > configure (lib + exe)
Configuring koka-3.0.3...
koka       > build (lib + exe)
Preprocessing library for koka-3.0.3..
Building library for koka-3.0.3..
[  1 of 102] Compiling Common.Id
[  2 of 102] Compiling Common.IdMap
(....)
[102 of 102] Compiling Interpreter.Interpret
Preprocessing executable 'koka' for koka-3.0.3..
Building executable 'koka' for koka-3.0.3..

<no location info>: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules for `main' :
        Syntax.Lexer
[ 1 of 17] Compiling LanguageServer.Conversions [Syntax.RangeMap package changed]
[ 2 of 17] Compiling LanguageServer.Handler.Pretty
[ 3 of 17] Compiling LanguageServer.Monad [Source file changed]
[ 4 of 17] Compiling LanguageServer.Handler.TextDocument [Source file changed]
[ 5 of 17] Compiling LanguageServer.Handler.Hover [Source file changed]
[ 6 of 17] Compiling LanguageServer.Handler.InlayHints [Source file changed]
[ 7 of 17] Compiling LanguageServer.Handler.Folding [Source file changed]
[ 8 of 17] Compiling LanguageServer.Handler.DocumentSymbol [Source file changed]
[ 9 of 17] Compiling LanguageServer.Handler.Definition [Source file changed]
[10 of 17] Compiling LanguageServer.Handler.Commands [Source file changed]
[11 of 17] Compiling Paths_koka [Source file changed]

[12 of 17] Compiling Syntax.Lexer [Syntax.Lexeme package changed]
.stack-work\dist\f1a1ac53\build\koka\koka-tmp\Syntax\Lexer.hs:376:26: error:
    * Couldn't match type `String -> Lex' with `Lex'
      Expected: Name -> Lex
        Actual: Name -> String -> Lex
    * Probable cause: `LexCons' is applied to too few arguments
      In the first argument of `(.)', namely `LexCons'
      In the second argument of `($)', namely `LexCons . newQName'
      In the expression: string $ LexCons . newQName
    |
376 | alex_action_5 = string $ LexCons . newQName
    |                          ^^^^^^^

.stack-work\dist\f1a1ac53\build\koka\koka-tmp\Syntax\Lexer.hs:384:26: error:
    * Couldn't match type `String -> Lex' with `Lex'
      Expected: Name -> Lex
        Actual: Name -> String -> Lex
    * Probable cause: `LexCons' is applied to too few arguments
      In the first argument of `(.)', namely `LexCons'
      In the second argument of `($)', namely `LexCons . newName'
      In the expression: string $ LexCons . newName
    |
384 | alex_action_9 = string $ LexCons . newName
    |                          ^^^^^^^

srcSyntaxLexer.x:548:15: error:
    * The constructor `LexCons' should have 2 arguments, but has been given 1
    * In the pattern: LexCons _
      In a case alternative: LexCons _ -> True
      In the expression:
        case prev of
          LexSpecial ")" -> True
          LexSpecial "]" -> True
          LexId _ -> True
          LexCons _ -> True
          LexIdOp _ -> True
          _ -> False
Completed 2 action(s).

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package koka-3.0.3 (scroll up to its section to see the error) using:
       C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_9p6GVs8J_3.8.1.0_ghc-9.4.8.exe --verbose=1 --builddir=.stack-work\dist\f1a1ac53 build lib:koka exe:koka exe:koka-plain --ghc-options " -fdiagnostics-color=always"
       Process exited with code: ExitFailure 1

Am I doing something wrong? According to the docs this should be enough to build the compiler.

Sometimes the lexer definition file (Lexer.x) get's out of sync with the generated file (Lexer.hs), but the build system doesn't detect that it needs to regenerate. If you do a stack clean --full or remove the .stack-work directory it will recompile the project from scratch, which should fix this issue. Alternatively you might be able to just get away with deleting the Lexer.hs file in src/Syntax/Lexer.hs, or making a trivial edit to the Lexer.x file compile, kill the compilation after it detects there is a change and compiles Lexer.hs, and then revert it and recompile.

Nevermind it looks like that file has moved locations since last time I worked with it. It is now generated into the build directory (on my system in .stack-work/dist/x86_64-osx/ghc-9.4.8/build/Syntax/Lexer.hs). You probably still have an old Lexer.hs in the src/Syntax/Lexer.hs location, and should just delete it.

Yep, it works now. Thanks for the response! I'll leave it up to you if you want to keep this issue open or close it.