[Git][ghc/ghc][wip/soulomoon/25647-allow-newtype-instance-in-gadt-syntax] 2 commits: wasm: prevent bundlers from resolving import("node:timers")
Patrick (@soulomoon)
gitlab at gitlab.haskell.org
Thu Jan 16 10:11:42 UTC 2025
Patrick pushed to branch wip/soulomoon/25647-allow-newtype-instance-in-gadt-syntax at Glasgow Haskell Compiler / GHC
Commits:
f6493dbc by amesgen at 2025-01-15T18:47:23-05:00
wasm: prevent bundlers from resolving import("node:timers")
This fixes the following esbuild error:
✘ [ERROR] Could not resolve "node:timers"
www/ghc_wasm_jsffi.js:66:25:
66 │ return (await import("node:timers")).setImmediate;
╵ ~~~~~~~~~~~~~
The package "node:timers" wasn't found on the file system but is built into node. Are you trying
to bundle for node? You can use "--platform=node" to do that, which will remove this error.
Previously (i.e. after !13503), one had to work around this by passing
`--external:node:timers`.
- - - - -
faeda39e by Patrick at 2025-01-16T18:10:43+08:00
update kcConDecl to also consider the result type
in newtype GADT instance
- - - - -
2 changed files:
- compiler/GHC/Tc/TyCl.hs
- utils/jsffi/prelude.mjs
Changes:
=====================================
compiler/GHC/Tc/TyCl.hs
=====================================
@@ -1865,7 +1865,7 @@ kcConDecl new_or_data tc_res_kind
-- because that's done in tcConDecl
}
-kcConDecl new_or_data _tc_res_kind
+kcConDecl new_or_data tc_res_kind
-- NB: _tc_res_kind is unused. See (KCD3) in
-- Note [kcConDecls: kind-checking data type decls]
(ConDeclGADT { con_names = names, con_bndrs = L _ outer_bndrs
@@ -1878,9 +1878,10 @@ kcConDecl new_or_data _tc_res_kind
-- Why "_Tv"? See Note [Using TyVarTvs for kind-checking GADTs]
do { _ <- tcHsContext cxt
; traceTc "kcConDecl:GADT {" (ppr names $$ ppr res_ty)
- ; con_res_kind <- newOpenTypeKind
- ; _ <- tcCheckLHsTypeInContext res_ty (TheKind con_res_kind)
-
+ ; con_res_kind <- if NewType == new_or_data
+ then return tc_res_kind
+ else newOpenTypeKind
+ ; _ <- tcCheckLHsTypeInContext res_ty $ (TheKind con_res_kind)
; let arg_exp_kind = getArgExpKind new_or_data con_res_kind
-- getArgExpKind: for newtypes, check that the argument kind
-- is the same the kind of `res_ty`, the data con's return type
@@ -4685,6 +4686,7 @@ checkValidDataCon dflags existential_ok tc con
res_ty_tmpl = mkFamilyTyConApp tc (mkTyVarTys tc_tvs)
arg_tys = dataConOrigArgTys con
orig_res_ty = dataConOrigResTy con
+ -- dc_eq_spec = dcEqSpec con
; traceTc "checkValidDataCon" (vcat
[ ppr con, ppr tc, ppr tc_tvs
@@ -4853,7 +4855,9 @@ checkNewDataCon con
; checkNoErrs $
-- Fail here if the newtype is invalid: subsequent code in
-- checkValidDataCon can fall over if it comes across an invalid newtype.
- do { case arg_tys of
+ do {
+ traceTc "checkNewDataCon > eq_spec:" (ppr eq_spec)
+ ; case arg_tys of
[Scaled arg_mult _] ->
unless (ok_mult arg_mult) $
addErrTc $
=====================================
utils/jsffi/prelude.mjs
=====================================
@@ -63,7 +63,9 @@ const setImmediate = await (async () => {
// deno
if (globalThis.Deno) {
- return (await import("node:timers")).setImmediate;
+ try {
+ return (await import("node:timers")).setImmediate;
+ } catch {}
}
// https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fcdf16e591743af1a358bbcc5727662102a4f653...faeda39ee025550473f077b32edca36c8c763d89
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fcdf16e591743af1a358bbcc5727662102a4f653...faeda39ee025550473f077b32edca36c8c763d89
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250116/2277798c/attachment-0001.html>
More information about the ghc-commits
mailing list