Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 0bfd29c3 by Cheng Shao at 2026-03-09T04:54:46-04:00 wasm: fix `Illegal foreign declaration` failure when ghci loads modules with JSFFI exports This patch fixes a wasm ghci error when loading modules with JSFFI exports; the `backendValidityOfCExport` check in `tcCheckFEType` should only makes sense and should be performed when not checking the JavaScript calling convention; otherwise, when the calling convention is JavaScript, the codegen logic should be trusted to backends that actually make use of it. Fixes #26998. - - - - - 3 changed files: - compiler/GHC/Tc/Gen/Foreign.hs - + testsuite/tests/ghci-wasm/T26998.hs - testsuite/tests/ghci-wasm/all.T Changes: ===================================== compiler/GHC/Tc/Gen/Foreign.hs ===================================== @@ -449,8 +449,9 @@ tcFExport d = pprPanic "tcFExport" (ppr d) tcCheckFEType :: Type -> ForeignExport GhcRn -> TcM (ForeignExport GhcTc) tcCheckFEType sig_ty edecl@(CExport src (L l (CExportStatic str cconv))) = do - checkCg (Left edecl) backendValidityOfCExport - when (cconv /= JavaScriptCallConv) $ checkTc (isCLabelString str) (TcRnInvalidCIdentifier str) + when (cconv /= JavaScriptCallConv) $ do + checkCg (Left edecl) backendValidityOfCExport + checkTc (isCLabelString str) (TcRnInvalidCIdentifier str) cconv' <- checkCConv (Left edecl) cconv checkForeignArgs isFFIExternalTy arg_tys checkForeignRes nonIOok noCheckSafe isFFIExportResultTy res_ty ===================================== testsuite/tests/ghci-wasm/T26998.hs ===================================== @@ -0,0 +1,4 @@ +main :: IO () +main = pure () + +foreign export javascript "my_main" main :: IO () ===================================== testsuite/tests/ghci-wasm/all.T ===================================== @@ -10,3 +10,5 @@ test('T26430', [ extra_hc_opts('-L. -lT26430B')] , compile_and_run, [''] ) + +test('T26998', [], compile_and_run, ['']) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bfd29c3d233da282e96e89e5398cfd7... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0bfd29c3d233da282e96e89e5398cfd7... You're receiving this email because of your account on gitlab.haskell.org.