[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Jul 12 15:58:39 UTC 2023



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
09a5c6cc by Josh Meredith at 2023-07-12T11:25:13-04:00
JavaScript: support unicode code points > 2^16 in toJSString using String.fromCodePoint (#23628)

- - - - -
29fbbd4e by Matthew Pickering at 2023-07-12T11:25:49-04:00
Remove references to make build system in mk/build.mk

Fixes #23636

- - - - -
630e3026 by sheaf at 2023-07-12T11:26:43-04:00
Valid hole fits: don't panic on a Given

The function GHC.Tc.Errors.validHoleFits would end up panicking when
encountering a Given constraint. To fix this, it suffices to filter out
the Givens before continuing.

Fixes #22684

- - - - -
3625e510 by Matthew Pickering at 2023-07-12T11:58:18-04:00
Use deb10 for i386 bindists

deb9 is now EOL so it's time to upgrade the i386 bindist to use deb10

Fixes #23585

- - - - -
0df66682 by Krzysztof Gogolewski at 2023-07-12T11:58:18-04:00
Fix #23567, a specializer bug

Found by Simon in https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507834

The testcase isn't ideal because it doesn't detect the bug in master,
unless doNotUnbox is removed as in
https://gitlab.haskell.org/ghc/ghc/-/issues/23567#note_507692.
But I have confirmed that with that modification, it fails before
and passes afterwards.

- - - - -
09efcdd9 by Bartłomiej Cieślar at 2023-07-12T11:58:23-04:00
Comments

- - - - -
3e3a242c by Bartłomiej Cieślar at 2023-07-12T11:58:23-04:00
updates to comments

- - - - -
baaa2882 by Bartłomiej Cieślar at 2023-07-12T11:58:23-04:00
changes

- - - - -


20 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- .gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Types/Name.hs
- rts/js/string.js
- testsuite/tests/javascript/js-ffi-string.hs
- testsuite/tests/javascript/js-ffi-string.stdout
- + testsuite/tests/simplCore/should_compile/T23567.hs
- + testsuite/tests/simplCore/should_compile/T23567A.hs
- testsuite/tests/simplCore/should_compile/all.T
- + testsuite/tests/typecheck/should_fail/T22684.hs
- + testsuite/tests/typecheck/should_fail/T22684.stderr
- testsuite/tests/typecheck/should_fail/all.T


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -2,7 +2,7 @@ variables:
   GIT_SSL_NO_VERIFY: "1"
 
   # Commit of ghc/ci-images repository from which to pull Docker images
-  DOCKER_REV: 243a00f06550e6b9a00fa0f1530d1bb761e8b7cc
+  DOCKER_REV: e0874d9716897188a8ba059d2245269ed541bf9d
 
   # Sequential version number of all cached things.
   # Bump to invalidate GitLab CI cache.
@@ -1048,7 +1048,7 @@ ghcup-metadata-nightly:
       artifacts: false
     - job: nightly-x86_64-linux-deb9-validate
       artifacts: false
-    - job: nightly-i386-linux-deb9-validate
+    - job: nightly-i386-linux-deb10-validate
       artifacts: false
     - job: nightly-x86_64-linux-deb10-validate
       artifacts: false


=====================================
.gitlab/ci.sh
=====================================
@@ -75,16 +75,6 @@ Environment variables affecting both build systems:
                     (either "x86-64-darwin" or "aarch-darwin")
   NO_BOOT           Whether to run ./boot or not, used when testing the source dist
 
-Environment variables determining build configuration of Make system:
-
-  BUILD_FLAVOUR     Which flavour to build.
-  BUILD_SPHINX_HTML Whether to build Sphinx HTML documentation.
-  BUILD_SPHINX_PDF  Whether to build Sphinx PDF documentation.
-  INTEGER_LIBRARY   Which integer library to use (integer-simple or integer-gmp).
-  HADDOCK_HYPERLINKED_SOURCES
-                    Whether to build hyperlinked Haddock sources.
-  TEST_TYPE         Which test rule to run.
-
 Environment variables determining build configuration of Hadrian system:
 
   BUILD_FLAVOUR     Which flavour to build.
@@ -390,26 +380,6 @@ function cleanup_submodules() {
   end_section "clean submodules"
 }
 
-function prepare_build_mk() {
-  if [[ -z "$BUILD_FLAVOUR" ]]; then fail "BUILD_FLAVOUR is not set"; fi
-  if [[ -z ${BUILD_SPHINX_HTML:-} ]]; then BUILD_SPHINX_HTML=YES; fi
-  if [[ -z ${BUILD_SPHINX_PDF:-} ]]; then BUILD_SPHINX_PDF=YES; fi
-
-  cat > mk/build.mk <<EOF
-BIGNUM_BACKEND=${BIGNUM_BACKEND}
-include mk/flavours/${BUILD_FLAVOUR}.mk
-GhcLibHcOpts+=-haddock
-EOF
-
-  if [ -n "${HADDOCK_HYPERLINKED_SOURCES:-}" ]; then
-    echo "EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump" >> mk/build.mk
-  fi
-
-
-  info "build.mk is:"
-  cat mk/build.mk
-}
-
 function configure() {
   case "${CONFIGURE_WRAPPER:-}" in
     emconfigure) source "$EMSDK/emsdk_env.sh" ;;


=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -928,7 +928,7 @@ job_groups =
      , standardBuilds AArch64 Darwin
      , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla)
      , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm)
-     , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla)
+     , standardBuildsWithConfig I386 (Linux Debian10) (splitSectionsBroken vanilla)
      -- Fully static build, in theory usable on any linux distribution.
      , fullyStaticBrokenTests (standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static))
      -- Dynamically linked build, suitable for building your own static executables on alpine


=====================================
.gitlab/jobs.yaml
=====================================
@@ -126,7 +126,7 @@
       "TEST_ENV": "aarch64-linux-deb10-validate"
     }
   },
-  "i386-linux-deb9-validate": {
+  "i386-linux-deb10-validate": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh save_test_output",
@@ -137,7 +137,7 @@
     "artifacts": {
       "expire_in": "2 weeks",
       "paths": [
-        "ghc-i386-linux-deb9-validate.tar.xz",
+        "ghc-i386-linux-deb10-validate.tar.xz",
         "junit.xml",
         "unexpected-test-output.tar.gz"
       ],
@@ -147,14 +147,14 @@
       "when": "always"
     },
     "cache": {
-      "key": "i386-linux-deb9-$CACHE_REV",
+      "key": "i386-linux-deb10-$CACHE_REV",
       "paths": [
         "cabal-cache",
         "toolchain"
       ]
     },
     "dependencies": [],
-    "image": "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV",
+    "image": "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb10:$DOCKER_REV",
     "needs": [
       {
         "artifacts": false,
@@ -180,11 +180,11 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-i386-linux-deb9-validate",
+      "BIN_DIST_NAME": "ghc-i386-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "",
       "RUNTEST_ARGS": "",
-      "TEST_ENV": "i386-linux-deb9-validate"
+      "TEST_ENV": "i386-linux-deb10-validate"
     }
   },
   "nightly-aarch64-darwin-validate": {
@@ -377,7 +377,7 @@
       "XZ_OPT": "-9"
     }
   },
-  "nightly-i386-linux-deb9-validate": {
+  "nightly-i386-linux-deb10-validate": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh save_test_output",
@@ -388,7 +388,7 @@
     "artifacts": {
       "expire_in": "8 weeks",
       "paths": [
-        "ghc-i386-linux-deb9-validate.tar.xz",
+        "ghc-i386-linux-deb10-validate.tar.xz",
         "junit.xml",
         "unexpected-test-output.tar.gz"
       ],
@@ -398,14 +398,14 @@
       "when": "always"
     },
     "cache": {
-      "key": "i386-linux-deb9-$CACHE_REV",
+      "key": "i386-linux-deb10-$CACHE_REV",
       "paths": [
         "cabal-cache",
         "toolchain"
       ]
     },
     "dependencies": [],
-    "image": "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV",
+    "image": "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb10:$DOCKER_REV",
     "needs": [
       {
         "artifacts": false,
@@ -431,11 +431,11 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-i386-linux-deb9-validate",
+      "BIN_DIST_NAME": "ghc-i386-linux-deb10-validate",
       "BUILD_FLAVOUR": "validate",
       "CONFIGURE_ARGS": "",
       "RUNTEST_ARGS": "",
-      "TEST_ENV": "i386-linux-deb9-validate",
+      "TEST_ENV": "i386-linux-deb10-validate",
       "XZ_OPT": "-9"
     }
   },
@@ -2536,7 +2536,7 @@
       "XZ_OPT": "-9"
     }
   },
-  "release-i386-linux-deb9-release+no_split_sections": {
+  "release-i386-linux-deb10-release+no_split_sections": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh save_test_output",
@@ -2547,7 +2547,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-i386-linux-deb9-release+no_split_sections.tar.xz",
+        "ghc-i386-linux-deb10-release+no_split_sections.tar.xz",
         "junit.xml",
         "unexpected-test-output.tar.gz"
       ],
@@ -2557,14 +2557,14 @@
       "when": "always"
     },
     "cache": {
-      "key": "i386-linux-deb9-$CACHE_REV",
+      "key": "i386-linux-deb10-$CACHE_REV",
       "paths": [
         "cabal-cache",
         "toolchain"
       ]
     },
     "dependencies": [],
-    "image": "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV",
+    "image": "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb10:$DOCKER_REV",
     "needs": [
       {
         "artifacts": false,
@@ -2590,13 +2590,13 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-i386-linux-deb10-release+no_split_sections",
       "BUILD_FLAVOUR": "release+no_split_sections",
       "CONFIGURE_ARGS": "",
       "HADRIAN_ARGS": "--hash-unit-ids",
       "IGNORE_PERF_FAILURES": "all",
       "RUNTEST_ARGS": "",
-      "TEST_ENV": "i386-linux-deb9-release+no_split_sections",
+      "TEST_ENV": "i386-linux-deb10-release+no_split_sections",
       "XZ_OPT": "-9"
     }
   },


=====================================
.gitlab/rel_eng/fetch-gitlab-artifacts/fetch_gitlab.py
=====================================
@@ -34,6 +34,7 @@ def job_triple(job_name):
         'release-x86_64-linux-alpine3_12-int_native-release+fully_static': 'x86_64-alpine3_12-linux-static-int_native',
         'release-x86_64-darwin-release': 'x86_64-apple-darwin',
         'release-i386-linux-deb9-release': 'i386-deb9-linux',
+        'release-i386-linux-deb10-release': 'i386-deb10-linux',
         'release-armv7-linux-deb10-release': 'armv7-deb10-linux',
         'release-aarch64-linux-deb10-release': 'aarch64-deb10-linux',
         'release-aarch64-darwin-release': 'aarch64-apple-darwin',


=====================================
.gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
=====================================
@@ -191,7 +191,7 @@ def mk_new_yaml(release_mode, version, date, pipeline_type, job_map):
     deb10 = mk(debian("x86_64", 10))
     deb11 = mk(debian("x86_64", 11))
     deb10_arm64 = mk(debian("aarch64", 10))
-    deb9_i386 = mk(debian("i386", 9))
+    deb10_i386 = mk(debian("i386", 10))
 
     source = mk_one_metadata(release_mode, version, job_map, source_artifact)
     test = mk_one_metadata(release_mode, version, job_map, test_artifact)
@@ -221,10 +221,10 @@ def mk_new_yaml(release_mode, version, date, pipeline_type, job_map):
 
           }
 
-    a32 = { "Linux_Debian": { "<10": deb9_i386, "unknown_versioning": deb9_i386 }
-          , "Linux_Ubuntu": { "unknown_versioning": deb9_i386 }
-          , "Linux_Mint" : { "unknown_versioning": deb9_i386 }
-          , "Linux_UnknownLinux" : { "unknown_versioning": deb9_i386 }
+    a32 = { "Linux_Debian": { "unknown_versioning": deb10_i386 }
+          , "Linux_Ubuntu": { "unknown_versioning": deb10_i386 }
+          , "Linux_Mint" : { "unknown_versioning": deb10_i386 }
+          , "Linux_UnknownLinux" : { "unknown_versioning": deb10_i386 }
           }
 
     arm64 = { "Linux_UnknownLinux": { "unknown_versioning": deb10_arm64 }


=====================================
compiler/GHC/Core/Opt/Specialise.hs
=====================================
@@ -1495,7 +1495,9 @@ specBind top_lvl env (NonRec fn rhs) do_body
              -- Destroying demand info is not terrible; specialisation is
              -- always followed soon by demand analysis.
 
-             body_env2 = body_env1 `extendInScope` fn3
+             body_env2 = body_env1 `bringFloatedDictsIntoScope` ud_binds rhs_uds
+                                   `extendInScope` fn3
+                                   -- bringFloatedDictsIntoScope: see #23567
 
        ; (body', body_uds) <- do_body body_env2
 


=====================================
compiler/GHC/Iface/Tidy.hs
=====================================
@@ -8,7 +8,34 @@
 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 -}
 
--- | Tidying up Core
+{-| Tidying up Core
+
+This module's purpose is to prepare the Core program for two distinct purposes:
+* To be serialised into the module's interface file
+* To feed to the code generator
+
+The most important tasks are:
+* Determine which `Name`s should ultimately be `Internal` and `External`
+  (which may differ to whether they were originally `Internal` or `External`).
+  See `Note [About the NameSorts]` in GHC.Types.Name.
+  For example, in:
+          module M where
+            f x = x + y
+              where y = factorial 4
+  could be optimized during the Core pass to:
+          module M where
+            y = factorial 4
+            f x = x + y
+  in which case `y` would be changed from `Internal` to `External`.
+
+* Rename local identifiers to avoid name clashes, so that unfoldings etc can
+  be serialialised using the OccName, without Uniques.
+
+  For example (`x_5` means `x` with a `Unique` of `5`):
+          f x_12 x_23 = x_12
+  would be changed to:
+          f x_12 x1_23 = x_12
+-}
 module GHC.Iface.Tidy
   ( TidyOpts (..)
   , UnfoldingExposure (..)


=====================================
compiler/GHC/Tc/Errors.hs
=====================================
@@ -1563,16 +1563,19 @@ validHoleFits :: SolverReportErrCtxt    -- ^ The context we're in, i.e. the
                 -- the valid hole fits.
 validHoleFits ctxt@(CEC { cec_encl = implics
                         , cec_tidy = lcl_env}) simps hole
-  = do { (tidy_env, fits) <- findValidHoleFits lcl_env implics (map mk_wanted simps) hole
+  = do { (tidy_env, fits) <- findValidHoleFits lcl_env implics (mapMaybe mk_wanted simps) hole
        ; return (ctxt {cec_tidy = tidy_env}, fits) }
   where
-    mk_wanted :: ErrorItem -> CtEvidence
-    mk_wanted (EI { ei_pred = pred, ei_evdest = Just dest, ei_loc = loc })
-         = CtWanted { ctev_pred      = pred
-                    , ctev_dest      = dest
-                    , ctev_loc       = loc
-                    , ctev_rewriters = emptyRewriterSet }
-    mk_wanted item = pprPanic "validHoleFits no evdest" (ppr item)
+    mk_wanted :: ErrorItem -> Maybe CtEvidence
+    mk_wanted (EI { ei_pred = pred, ei_evdest = m_dest, ei_loc = loc })
+      | Just dest <- m_dest
+      = Just (CtWanted { ctev_pred      = pred
+                       , ctev_dest      = dest
+                       , ctev_loc       = loc
+                       , ctev_rewriters = emptyRewriterSet })
+      | otherwise
+      = Nothing   -- The ErrorItem was a Given
+
 
 -- See Note [Constraints include ...]
 givenConstraints :: SolverReportErrCtxt -> [(Type, RealSrcSpan)]


=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -4867,7 +4867,9 @@ data ErrorItem
   = EI { ei_pred     :: PredType         -- report about this
          -- The ei_pred field will never be an unboxed equality with
          -- a (casted) tyvar on the right; this is guaranteed by the solver
-       , ei_evdest   :: Maybe TcEvDest   -- for Wanteds, where to put evidence
+       , ei_evdest   :: Maybe TcEvDest
+         -- ^ for Wanteds, where to put the evidence
+         --   for Givens, Nothing
        , ei_flavour  :: CtFlavour
        , ei_loc      :: CtLoc
        , ei_m_reason :: Maybe CtIrredReason  -- if this ErrorItem was made from a


=====================================
compiler/GHC/Types/Name.hs
=====================================
@@ -143,12 +143,16 @@ data Name = Name
 -- See Note [About the NameSorts]
 data NameSort
   = External Module
+        -- Either an import from another module
+        -- or a top-level name
+        -- See Note [About the NameSorts]
 
   | WiredIn Module TyThing BuiltInSyntax
         -- A variant of External, for wired-in things
 
-  | Internal            -- A user-defined Id or TyVar
+  | Internal            -- A user-defined local Id or TyVar
                         -- defined in the module being compiled
+                        -- See Note [About the NameSorts]
 
   | System              -- A system-defined Id or TyVar.  Typically the
                         -- OccName is very uninformative (like 's')
@@ -213,21 +217,32 @@ TL;DR: we make the `n_occ` field lazy.
 {-
 Note [About the NameSorts]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-1.  Initially, top-level Ids (including locally-defined ones) get External names,
-    and all other local Ids get Internal names
-
-2.  In any invocation of GHC, an External Name for "M.x" has one and only one
+1.  Initially:
+    * All types, classes, data constructors get Extenal Names
+    * Top-level Ids (including locally-defined ones) get External Names,
+    * All other local (non-top-level) Ids get Internal names
+
+2.  In the Tidy phase (GHC.Iface.Tidy):
+      * An Id that is "externally-visible" is given an External Name,
+        even if the name was Internal up to that point
+      * An Id that is not externally visible is given an Internal Name.
+        even if the name was External up to that point
+    See GHC.Iface.Tidy.tidyTopName
+
+    An Id is externally visible if it is mentioned in the interface file; e.g.
+        - it is exported
+        - it is mentioned in an unfolding
+    See GHC.Iface.Tidy.chooseExternalIds
+
+3.  In any invocation of GHC, an External Name for "M.x" has one and only one
     unique.  This unique association is ensured via the Name Cache;
     see Note [The Name Cache] in GHC.Iface.Env.
 
-3.  Things with a External name are given C static labels, so they finally
-    appear in the .o file's symbol table.  They appear in the symbol table
-    in the form M.n.  If originally-local things have this property they
-    must be made @External@ first.
+4.  In code generation, things with a External name are given C static
+    labels, so they finally appear in the .o file's symbol table.  They
+    appear in the symbol table in the form M.n. That is why
+    externally-visible things are made External (see (2) above).
 
-4.  In the tidy-core phase, a External that is not visible to an importer
-    is changed to Internal, and a Internal that is visible is changed to External
 
 5.  A System Name differs in the following ways:
         a) has unique attached when printing dumps
@@ -239,13 +254,13 @@ Note [About the NameSorts]
     If any desugarer sys-locals have survived that far, they get changed to
     "ds1", "ds2", etc.
 
-Built-in syntax => It's a syntactic form, not "in scope" (e.g. [])
+6. A WiredIn Name is used for things (Id, TyCon) that are fully known to the compiler,
+   not read from an interface file. E.g. Bool, True, Int, Float, and many others.
 
-Wired-in thing  => The thing (Id, TyCon) is fully known to the compiler,
-                   not read from an interface file.
-                   E.g. Bool, True, Int, Float, and many others
+   A WiredIn Name contains contains a TyThing, so we don't have to look it up.
 
-All built-in syntax is for wired-in things.
+   The BuiltInSyntax flag => It's a syntactic form, not "in scope" (e.g. [])
+   All built-in syntax thigs are WiredIn.
 -}
 
 instance HasOccName Name where


=====================================
rts/js/string.js
=====================================
@@ -628,7 +628,7 @@ function h$fromHsString(str) {
     var xs = '';
     while(IS_CONS(str)) {
 	var h = CONS_HEAD(str);
-	xs += String.fromCharCode(UNWRAP_NUMBER(h));
+	xs += String.fromCodePoint(UNWRAP_NUMBER(h));
         str = CONS_TAIL(str);
     }
     return xs;


=====================================
testsuite/tests/javascript/js-ffi-string.hs
=====================================
@@ -1,13 +1,49 @@
 import GHC.JS.Prim
+import System.IO
 
 foreign import javascript "((x) => { console.log(x); })"
   log_js_string :: JSVal -> IO ()
 
-foreign import javascript "(() => { return 'a string'; })"
-  a_string :: JSVal
+foreign import javascript "((x, y) => { return x === y; })"
+  eq_JSVal :: JSVal -> JSVal -> Bool
+
+foreign import javascript "(() => { return 'abc\\uD83D\\uDE0A'; })"
+  js_utf16_string :: JSVal
+foreign import javascript "(() => { return 'abc' + String.fromCodePoint(128522); })"
+  js_codepoint_string :: JSVal
+
+-- It's important that this String is defined using a function to avoid rewrite
+-- rules optimising away the use of `toJSString` called on a literal.
+hsString :: String
+hsString = "abc" ++ "\128522"
 
 main :: IO ()
 main = do
-  log_js_string (toJSString "test")
-  putStrLn (fromJSString a_string)
-  putStrLn (fromJSString $ toJSString "test")
+  putStrLn "Does JS `String.fromCodePoint` decode to the expected UTF-16 values? "
+  print (eq_JSVal js_utf16_string js_codepoint_string)
+  hFlush stdout
+  log_js_string js_utf16_string
+  log_js_string js_codepoint_string
+
+  putStrLn "\nDoes `GHC.JS.fromJSString` convert the JavaScript literal string correctly? "
+  print (hsString == fromJSString js_utf16_string)
+  putStrLn hsString
+  putStrLn (fromJSString js_utf16_string)
+
+  putStrLn "\nDoes `GHC.JS.toJSString` convert the Haskell-defined string correctly? "
+  print (eq_JSVal js_utf16_string (toJSString hsString))
+  hFlush stdout
+  log_js_string js_utf16_string
+  log_js_string (toJSString hsString)
+
+  putStrLn "\nDo values survive the Haskell -> JavaScript -> Haskell round-trip? "
+  print (hsString == fromJSString (toJSString hsString))
+  putStrLn hsString
+  putStrLn (fromJSString js_utf16_string)
+
+  putStrLn "\nDo values survive the JavaScript -> Haskell -> JavaScript round-trip? "
+  print (eq_JSVal js_utf16_string (toJSString $ fromJSString js_utf16_string))
+  hFlush stdout
+  log_js_string js_utf16_string
+  log_js_string (toJSString $ fromJSString js_utf16_string)
+


=====================================
testsuite/tests/javascript/js-ffi-string.stdout
=====================================
@@ -1,3 +1,25 @@
-test
-a string
-test
+Does JS `String.fromCodePoint` decode to the expected UTF-16 values? 
+True
+abc😊
+abc😊
+
+Does `GHC.JS.fromJSString` convert the JavaScript literal string correctly? 
+True
+abc😊
+abc😊
+
+Does `GHC.JS.toJSString` convert the Haskell-defined string correctly? 
+True
+abc😊
+abc😊
+
+Do values survive the Haskell -> JavaScript -> Haskell round-trip? 
+True
+abc😊
+abc😊
+
+Do values survive the JavaScript -> Haskell -> JavaScript round-trip? 
+True
+abc😊
+abc😊
+


=====================================
testsuite/tests/simplCore/should_compile/T23567.hs
=====================================
@@ -0,0 +1,10 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# OPTIONS_GHC -funfolding-use-threshold=111640 -fmax-simplifier-iterations=2 #-}
+
+module T23567 where
+
+import T23567A
+
+instance (MonadIO m) => CacheRWM2 (ReaderT (StateT m)) where
+  p = runCacheBuildM
+  {-# NOINLINE p #-}


=====================================
testsuite/tests/simplCore/should_compile/T23567A.hs
=====================================
@@ -0,0 +1,27 @@
+module T23567A where
+
+class Appl f where
+  pur :: f
+  ast :: f -> f
+
+class Appl f => Mona f where
+  unused :: f
+
+class Mona f => MonadIO f where
+  unused2 :: f
+
+newtype StateT m = StateT { runStateT :: m }
+  deriving (Mona, MonadIO)
+
+instance (Appl m, Appl m) => Appl (StateT m) where
+    pur = pur
+    ast x = x
+
+newtype ReaderT m = ReaderT { runReaderT :: m }
+  deriving (Appl, Mona, MonadIO)
+
+class CacheRWM2 m where
+  p :: m
+
+runCacheBuildM :: (MonadIO m) => m
+runCacheBuildM = ast pur


=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -490,3 +490,4 @@ test('T23491c', [extra_files(['T23491.hs']), grep_errmsg(r'Liberate case')], mul
 test('T23491d', [extra_files(['T23491.hs']), grep_errmsg(r'Static argument')], multimod_compile, ['T23491', '-fstatic-argument-transformation -ddump-static-argument-transformation'])
 test('T23074', normal, compile, ['-O -ddump-rules'])
 test('T23272', [only_ways(['ghci']), extra_hc_opts('-fno-unoptimized-core-for-interpreter -O')], ghci_script, ['T23272.script'])
+test('T23567', [extra_files(['T23567A.hs'])], multimod_compile, ['T23567', '-O -v0'])


=====================================
testsuite/tests/typecheck/should_fail/T22684.hs
=====================================
@@ -0,0 +1,19 @@
+module T22684 where
+
+-- Example 1 from #22684
+p :: (Int ~ Bool => r) -> r
+p _ = undefined
+
+q :: r
+q = p _
+
+-- Example 3 from #22684
+class Category k where
+  (.) :: k b c -> k a b -> k a c
+
+data Free p a b where
+  Prod :: Free p a (b, c)
+  Sum  :: Free p (Either a b) c
+
+instance Category (Free p) where
+  Sum . Prod = _


=====================================
testsuite/tests/typecheck/should_fail/T22684.stderr
=====================================
@@ -0,0 +1,35 @@
+
+T22684.hs:8:7: error: [GHC-88464]
+    • Found hole: _ :: r
+      Where: ‘r’ is a rigid type variable bound by
+               the type signature for:
+                 q :: forall r. r
+               at T22684.hs:7:1-6
+    • In the first argument of ‘p’, namely ‘_’
+      In the expression: p _
+      In an equation for ‘q’: q = p _
+    • Relevant bindings include q :: r (bound at T22684.hs:8:1)
+      Constraints include Int ~ Bool (from T22684.hs:8:7)
+      Valid hole fits include q :: r (bound at T22684.hs:8:1)
+
+T22684.hs:19:16: error: [GHC-88464]
+    • Found hole: _ :: Free p a c
+      Where: ‘k’, ‘p’ are rigid type variables bound by
+               the instance declaration
+               at T22684.hs:18:10-26
+             ‘a’, ‘c’ are rigid type variables bound by
+               the type signature for:
+                 (T22684..) :: forall b c a. Free p b c -> Free p a b -> Free p a c
+               at T22684.hs:19:7
+    • In an equation for ‘T22684..’: Sum T22684.. Prod = _
+      In the instance declaration for ‘Category (Free p)’
+    • Relevant bindings include
+        (.) :: Free p b c -> Free p a b -> Free p a c
+          (bound at T22684.hs:19:7)
+      Constraints include
+        b ~ (b2, c1) (from T22684.hs:19:9-12)
+        b ~ Either a1 b1 (from T22684.hs:19:3-5)
+      Valid hole fits include
+        q :: forall r. r
+          with q @(Free p a c)
+          (bound at T22684.hs:8:1)


=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -696,4 +696,5 @@ test('VisFlag2', normal, compile_fail, [''])
 test('VisFlag3', normal, compile_fail, [''])
 test('VisFlag4', normal, compile_fail, [''])
 test('VisFlag5', normal, compile_fail, [''])
+test('T22684', normal, compile_fail, [''])
 test('T23514a', normal, compile_fail, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a61593be51d23938fcdbd702ad5aab1a4cd2107...baaa288294fd7145fce18be1cba5b95e2b199e86

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7a61593be51d23938fcdbd702ad5aab1a4cd2107...baaa288294fd7145fce18be1cba5b95e2b199e86
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/20230712/e2a9a19c/attachment-0001.html>


More information about the ghc-commits mailing list