Mutually recursive foreign import data declarations can cause an internal compiler error on the current master.
module Main where
foreign import data A :: B
foreign import data B :: A
purescript > 'RecursiveExternData.purs' should compile and run without error: FAIL (0.07s)
purescript > uncaught exception: ErrorCall
purescript > An internal error occurred during compilation: toExternsDeclaration: no kind
in toExternsDeclaration
purescript > Please report this at https://github.com/purescript/purescript/issues
purescript > CallStack (from HasCallStack):
purescript > error, called at src/Language/PureScript/Crash.hs:24:3 in purescript-ast-0.
1.0.0-Gtmwmu4N43KCxo7Qi9BiwQ:Language.PureScript.Crash
purescript > internalError, called at src/Language/PureScript/Externs.hs:225:18 in pures
cript-0.13.8-8vNPQdyw1kRA1yYdlrf0He:Language.PureScript.Externs
I'm not sure whether this should be rejected by the compiler or not, but it should at least not result in an internal compiler error.
Came across this while trying to implement the refactoring described in https://github.com/purescript/purescript/pull/3910#issuecomment-680252963 - it seems like ExternDataDeclaration values are not designed to be part of a DataBindingGroup.
master
If I write this in GHCi
data A :: B
data B :: A
I get this:
• Type constructor ‘A’ cannot be used here
(it is defined and used in the same recursive group)
• In the kind ‘A’
I think that it should be rejected by the binding group toposort.
isKindDecl does not consider foreign data a kind declaration, even though it is.
The existing error is CycleInKindDeclaration.
Most helpful comment
I think that it should be rejected by the binding group toposort.