Unisay / purescript-lua

Purescript compiler back-end for Lua
GNU General Public License v3.0
55 stars 2 forks source link

Optimizer errors with `pslua: Impossible subexpressions: IfThenElse` #30

Open Renegatto opened 2 months ago

Renegatto commented 2 months ago

The error is:

PS Lua: compiling ...
pslua: Impossible subexpressions: IfThenElse
CallStack (from HasCallStack):
  error, called at src/Relude/Debug.hs:296:11 in relude-1.2.1.0-InE73P0BzGI4tF0Ie3lTIC:Relude.Debug
  error, called at lib/Language/PureScript/Backend/Lua/Optimizer.hs:202:17 in pslua-0.1.0.0-2hkO0AwfMEO5Nw1JAHZE53:Language.PureScript.Backend.Lua.Optimizer

How to reproduce

Minimal example I have got:

module Main (main) where

import Prelude (Unit, pure, map)

import Data.Maybe (Maybe(Just, Nothing), maybe)
import Effect (Effect)
import Effect.Exception (throw)

main :: Effect Unit
main =
  maybe
    (throw "Some error")
    pure
    (maybe Nothing Just (map (\x -> x) Nothing))

When compiled as a module (e.g. with no entrypoint)

Environment

Template

Based on github.com/purescript-lua-template/commit/9e0920a74d376e61a35be4f7389a6c2758cc1dd3

Compiler

github:Unisay/purescript-lua?rev=cc32d90b291f3d828747b31424db321a23b8f957

This is the version that still works with purescript-lua-template, see https://github.com/Unisay/purescript-lua-template/issues/1.

Package set

Custom package set, the only difference with the one that purescript-lua-template uses is:

, refs =
  { dependencies = [ "effect", "prelude" ]
  , repo = "https://github.com/Renegatto/purescript-lua-refs.git"
  , version = "1b6264b8cb62563e924eefa690e07ff4efa42f31"
  }

Which contain a fix for https://github.com/Unisay/purescript-lua/issues/29