tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
938 stars 83 forks source link

Language pragma `JavaScriptFFI` can't be parsed #1087

Closed amesgen closed 6 months ago

amesgen commented 6 months ago

The snippet

{-# LANGUAGE JavaScriptFFI #-}

can't be formatted due to

<input>:1:1
  The GHC parser (in Haddock mode) failed:
  <input>:1:14: error: [GHC-46537]
    Unsupported extension: JavaScriptFFI

This is because JavaScriptFFI is only available for the JS backend currently, and so also on the WASM backend (see this GHC commit, first present in GHC 9.8, and upcoming merge request !11530 for JS FFI support for the WASM backend), but we currently set arch/OS to "unknown": https://github.com/tweag/ormolu/blob/05647fd4743ddd0490603625e72b094fba2cc078/src/GHC/DynFlags.hs#L29-L30

But we are only parsing the code, so there is no reason why Ormolu shouldn't be able to format this code.