diff options
author | Luite Stegeman <stegeman@gmail.com> | 2023-02-01 15:00:29 +0900 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2023-02-23 14:05:44 -0500 |
commit | 54fc7394040e42aea3b088bc6a3d0bb4f6bb533d (patch) | |
tree | 15e3849f70ffdc1c156ea34ada2497e404710f5c /compiler | |
parent | e0cfea59a3027a48d4d51b0b80b7b1e42183c274 (diff) | |
download | haskell-54fc7394040e42aea3b088bc6a3d0bb4f6bb533d.tar.gz |
Check for platform support for JavaScript foreign imports
GHC was accepting `foreign import javascript` declarations
on non-JavaScript platforms. This adds a check so that these
are only supported on an platform that supports the JavaScript
calling convention.
Fixes #22774
(cherry picked from commit 1d7c2e4c9d63a7b392024cfcde299849b8d667a8)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Tc/Gen/Foreign.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Gen/Foreign.hs b/compiler/GHC/Tc/Gen/Foreign.hs index caa7feeca7..31c42f86d6 100644 --- a/compiler/GHC/Tc/Gen/Foreign.hs +++ b/compiler/GHC/Tc/Gen/Foreign.hs @@ -341,9 +341,10 @@ tcCheckFIType arg_tys res_ty idecl@(CImport src (L lc cconv) (L ls safety) mh checkForeignRes nonIOok checkSafe (isFFIPrimResultTy dflags) res_ty return (CImport src (L lc cconv) (L ls safety) mh (CFunction target)) | cconv == JavaScriptCallConv = do + cconv' <- checkCConv (Right idecl) cconv checkCg (Right idecl) backendValidityOfCImport -- leave the rest to the JS backend (at least for now) - return (CImport src (L lc cconv) (L ls safety) mh (CFunction target)) + return (CImport src (L lc cconv') (L ls safety) mh (CFunction target)) | otherwise = do -- Normal foreign import checkCg (Right idecl) backendValidityOfCImport cconv' <- checkCConv (Right idecl) cconv |