merijn / validated-literals

Compile-time checking for partial smart-constructors
BSD 3-Clause "New" or "Revised" License
20 stars 3 forks source link

No error when invalid literal used in IO in repl #4

Closed olligobber closed 3 years ago

olligobber commented 3 years ago

When an invalid literal is used to create an IO x in ghci, no error occurs.

Prelude> :set -XTemplateHaskell
Prelude> :m Functional.Iota.Free ValidLiterals 
Prelude Functional.Iota.Free ValidLiterals> ($$(valid '(') :: IFree)

<interactive>:3:5: error:
    • Invalid input used for type-safe validated literal!
An error occured during compile-time validation!

    • In the Template Haskell splice $$(valid '(')
      In the expression: ($$(valid '(') :: IFree)
      In an equation for ‘it’: it = ($$(valid '(') :: IFree)

<interactive>:3:5: error:
    • Exception when trying to run compile-time code:
        ValidationFailure "An error occured during compile-time validation!"
      Code: valid '('
    • In the Template Haskell splice $$(valid '(')
      In the expression: ($$(valid '(') :: IFree)
      In an equation for ‘it’: it = ($$(valid '(') :: IFree)
Prelude Functional.Iota.Free ValidLiterals> print ($$(valid '(') :: IFree)
Prelude Functional.Iota.Free ValidLiterals> print ($$(valid 'a') :: IFree)
IFree {fromIFree = 'a'}
Prelude Functional.Iota.Free ValidLiterals>
olligobber commented 3 years ago

This is an error in GHCi, not validated-literals. See bug report here: https://gitlab.haskell.org/ghc/ghc/-/issues/19470