From debfc2e4e1e859bde3f679850767acd545a0d0f4 Mon Sep 17 00:00:00 2001 From: Justin Garcia Date: Tue, 27 Feb 2024 03:16:09 +0800 Subject: [PATCH 1/5] Fix compiler crash when a type operator is used in a type argument (#4536) Add missing traversal branch for VisibleTypeApp in updateTypes --- CHANGELOG.d/fix_issue-4535.md | 1 + src/Language/PureScript/Sugar/Operators.hs | 3 ++ tests/purs/passing/4535.purs | 43 ++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 CHANGELOG.d/fix_issue-4535.md create mode 100644 tests/purs/passing/4535.purs diff --git a/CHANGELOG.d/fix_issue-4535.md b/CHANGELOG.d/fix_issue-4535.md new file mode 100644 index 0000000000..77341885a9 --- /dev/null +++ b/CHANGELOG.d/fix_issue-4535.md @@ -0,0 +1 @@ +* Fix compiler crash when a type operator is used in a type argument diff --git a/src/Language/PureScript/Sugar/Operators.hs b/src/Language/PureScript/Sugar/Operators.hs index bb06486e82..93028d7e22 100644 --- a/src/Language/PureScript/Sugar/Operators.hs +++ b/src/Language/PureScript/Sugar/Operators.hs @@ -409,6 +409,9 @@ updateTypes goType = (goDecl, goExpr, goBinder) goExpr pos (TypedValue check v ty) = do ty' <- goType' pos ty return (pos, TypedValue check v ty') + goExpr pos (VisibleTypeApp v ty) = do + ty' <- goType' pos ty + return (pos, VisibleTypeApp v ty') goExpr pos other = return (pos, other) goBinder :: SourceSpan -> Binder -> m (SourceSpan, Binder) diff --git a/tests/purs/passing/4535.purs b/tests/purs/passing/4535.purs new file mode 100644 index 0000000000..424ba6e7e5 --- /dev/null +++ b/tests/purs/passing/4535.purs @@ -0,0 +1,43 @@ +module Main where + +import Prelude + +import Data.Maybe (Maybe(..)) +import Data.Tuple.Nested ((/\), type (/\)) +import Effect (Effect) +import Effect.Console (log) +import Type.Proxy (Proxy(..)) + +singleArgument :: forall @a. a -> Unit +singleArgument _ = unit + +multiArgument :: forall @a @b. a -> b -> Unit +multiArgument _ _ = unit + +singleApplication :: Int /\ Number -> Unit +singleApplication = singleArgument @(Int /\ Number) + +-- Like expression applications, visible type applications are left-associative. +-- This test accounts for subsequent type applications nested in this manner. +appNestingWorks :: Int /\ Number -> Number /\ Int -> Unit +appNestingWorks = multiArgument @(Int /\ Number) @(Number /\ Int) + +-- This test accounts for type applications nested within other AST nodes. +otherNestingWorks :: Array (Maybe (Int /\ Number)) +otherNestingWorks = [Just @(Int /\ Number) (0 /\ 0.0), Just @(Int /\ Number) (1 /\ 1.0)] + +type InSynonym = Int /\ Number + +-- This test accounts for type synonyms used as type arguments. +-- Since expansion happens during checking, InSynonym would expand +-- to an already-desugared type operator. This test exists for the +-- sake of redundancy. +inSynonym :: InSynonym -> Unit +inSynonym = singleArgument @InSynonym + +-- This test accounts for type operators used as type arguments directly. +operatorAsArgument :: Proxy (/\) +operatorAsArgument = Proxy @(/\) + +main :: Effect Unit +main = log "Done" From 851291e0fff69c24ef714f24653defa978c381e5 Mon Sep 17 00:00:00 2001 From: Justin Garcia Date: Tue, 16 Apr 2024 12:47:39 +0800 Subject: [PATCH 2/5] Upgrade to GHC 9.2.8 (#4537) * Update resolver to lts-20.26 * Update haskell/action to haskell-action --- .github/workflows/ci.yml | 8 ++++---- CHANGELOG.d/misc_ghc-bump.md | 1 + INSTALL.md | 4 ++-- purescript.cabal | 2 +- stack.yaml | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.d/misc_ghc-bump.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8efd13812b..25636a7a3c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ defaults: env: CI_PRERELEASE: "${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}" CI_RELEASE: "${{ github.event_name == 'release' }}" - STACK_VERSION: "2.9.3" + STACK_VERSION: "2.15.1" concurrency: # We never want two prereleases building at the same time, since they would @@ -55,7 +55,7 @@ jobs: include: - # If upgrading the Haskell image, also upgrade it in the lint job below os: ["ubuntu-latest"] - image: haskell:9.2.5@sha256:2597b0e2458165a6635906204f7fac43c22e7d2a46aca1235a811194bb6cd419 + image: haskell:9.2.8@sha256:b3b2f3909c7381bb96b8f18766f9407a3d6f61e0f07ea95e812583ac4f442cbb - os: ["macOS-11"] - os: ["windows-2019"] - os: ["self-hosted", "macos", "ARM64"] @@ -99,7 +99,7 @@ jobs: # and their Haskell environment is instead provided by a nix-shell # See https://github.com/purescript/purescript/pulls/4455 if: "!contains(matrix.os, 'ubuntu-latest') && !contains(matrix.os, 'self-hosted')" - uses: "haskell/actions/setup@v1" + uses: "haskell-actions/setup@v2" with: enable-stack: true stack-version: "${{ env.STACK_VERSION }}" @@ -231,7 +231,7 @@ jobs: # means our published binaries will work on the widest number of platforms. # But the HLint binary downloaded by this job requires a newer glibc # version. - container: haskell:9.2.5@sha256:2597b0e2458165a6635906204f7fac43c22e7d2a46aca1235a811194bb6cd419 + container: haskell:9.2.8@sha256:b3b2f3909c7381bb96b8f18766f9407a3d6f61e0f07ea95e812583ac4f442cbb steps: - # We need a proper Git repository, but the checkout step will unpack a tarball instead of doing a clone diff --git a/CHANGELOG.d/misc_ghc-bump.md b/CHANGELOG.d/misc_ghc-bump.md new file mode 100644 index 0000000000..a1222cf6d0 --- /dev/null +++ b/CHANGELOG.d/misc_ghc-bump.md @@ -0,0 +1 @@ +* Update Stackage snapshot to lts-20.26 and GHC to 9.2.8 diff --git a/INSTALL.md b/INSTALL.md index 041cd3315d..0bccc516c7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,12 +4,12 @@ If you are having difficulty installing the PureScript compiler, feel free to as ## Requirements -The PureScript compiler is built using GHC 9.2.5, and should be able to run on any operating system supported by GHC 9.2.5. In particular: +The PureScript compiler is built using GHC 9.2.8, and should be able to run on any operating system supported by GHC 9.2.8. In particular: * for Windows users, versions predating Vista are not officially supported, * for macOS / OS X users, versions predating Mac OS X 10.7 (Lion) are not officially supported. -See also for more details about the operating systems which GHC 9.2.5 supports. +See also for more details about the operating systems which GHC 9.2.8 supports. ## Official prebuilt binaries diff --git a/purescript.cabal b/purescript.cabal index 6550a803dd..0d32ce4814 100644 --- a/purescript.cabal +++ b/purescript.cabal @@ -119,7 +119,7 @@ common defaults TypeFamilies ViewPatterns build-tool-depends: - happy:happy ==1.20.0 + happy:happy ==1.20.1.1 build-depends: -- NOTE: Please do not edit these version constraints manually. They are -- deliberately made narrow because changing the dependency versions in diff --git a/stack.yaml b/stack.yaml index cbf7426e01..88b27b1a46 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1,6 @@ # Please update Haskell image versions under .github/workflows/ci.yml together to use the same GHC version # (or the CI build will fail) -resolver: lts-20.9 +resolver: lts-20.26 pvp-bounds: both packages: - '.' From 2070d479d133da9a7c33f7572ca7adb45a4c7aee Mon Sep 17 00:00:00 2001 From: Ryan Hendrickson Date: Tue, 16 Apr 2024 15:25:55 -0400 Subject: [PATCH 3/5] Remove Git upgrade step from CI (#4541) buster-backports no longer exists in debian/dists and it's breaking CI. The currently available version of Git in this container is 2.20.1, so we don't need this. --- .github/workflows/ci.yml | 16 ---------------- .../internal_remove-git-upgrade-step-in-ci.md | 1 + 2 files changed, 1 insertion(+), 16 deletions(-) create mode 100644 CHANGELOG.d/internal_remove-git-upgrade-step-in-ci.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25636a7a3c..e2991a9118 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,15 +69,6 @@ jobs: version: "${{ steps.build.outputs.version }}" steps: - - # We need a proper Git repository, but the checkout step will unpack a tarball instead of doing a clone - # if the Git version is less than 2.18. - name: "(Linux only) Install a newer version of Git" - if: "contains(matrix.os, 'ubuntu-latest')" - run: | - . /etc/os-release - echo deb http://deb.debian.org/debian "$VERSION_CODENAME"-backports main >> /etc/apt/sources.list - apt-get update && apt-get install -y git/"$VERSION_CODENAME"-backports - - # We need `gh` installed on the Linux version. Otherwise, release artifacts won't be uploaded. name: "(Linux only) Install gh" if: "contains(matrix.os, 'ubuntu-latest')" @@ -234,13 +225,6 @@ jobs: container: haskell:9.2.8@sha256:b3b2f3909c7381bb96b8f18766f9407a3d6f61e0f07ea95e812583ac4f442cbb steps: - - # We need a proper Git repository, but the checkout step will unpack a tarball instead of doing a clone - # if the Git version is less than 2.18. - name: "Install a newer version of Git" - run: | - . /etc/os-release - echo deb http://deb.debian.org/debian "$VERSION_CODENAME"-backports main >> /etc/apt/sources.list - apt-get update && apt-get install -y git/"$VERSION_CODENAME"-backports - uses: "actions/checkout@v2" - name: "Fix working directory ownership" diff --git a/CHANGELOG.d/internal_remove-git-upgrade-step-in-ci.md b/CHANGELOG.d/internal_remove-git-upgrade-step-in-ci.md new file mode 100644 index 0000000000..f7f622a96e --- /dev/null +++ b/CHANGELOG.d/internal_remove-git-upgrade-step-in-ci.md @@ -0,0 +1 @@ +* Remove the step that upgraded Git from the CI workflow From 08b6c758b53fface1769c05ca8bcf119db5c114c Mon Sep 17 00:00:00 2001 From: Fabrizio Ferrai Date: Thu, 25 Jul 2024 01:10:02 +0300 Subject: [PATCH 4/5] Upgrade macOS runner to 14 (#4548) Since the beginning of July GitHub has deprecated the macOS-11 runners that we were using, see [the announcement](https://github.blog/changelog/2024-05-20-actions-upcoming-changes-to-github-hosted-macos-runners/) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2991a9118..2cd314dbf1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,7 +56,7 @@ jobs: - # If upgrading the Haskell image, also upgrade it in the lint job below os: ["ubuntu-latest"] image: haskell:9.2.8@sha256:b3b2f3909c7381bb96b8f18766f9407a3d6f61e0f07ea95e812583ac4f442cbb - - os: ["macOS-11"] + - os: ["macOS-14"] - os: ["windows-2019"] - os: ["self-hosted", "macos", "ARM64"] - os: ["self-hosted", "Linux", "ARM64"] From e06b9ccb7cbf31633d25e55531d70dcda7ec28b2 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Thu, 25 Jul 2024 01:50:43 +0200 Subject: [PATCH 5/5] Fix imports for newer mtl versions (#4547) Newer mtl does not re-export Control.Monad and Data.Monoid anymore. So we fix that by splitting the imports manually. --- app/Command/Docs.hs | 2 +- app/Command/Docs/Html.hs | 2 +- src/Control/Monad/Supply.hs | 3 ++- src/Language/PureScript/Errors.hs | 3 ++- src/Language/PureScript/Renamer.hs | 3 ++- src/Language/PureScript/Sugar/Operators/Common.hs | 2 +- src/Language/PureScript/TypeChecker/Entailment.hs | 6 ++++-- src/Language/PureScript/TypeChecker/Monad.hs | 3 ++- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Command/Docs.hs b/app/Command/Docs.hs index f0b6711b09..987023c98c 100644 --- a/app/Command/Docs.hs +++ b/app/Command/Docs.hs @@ -6,7 +6,7 @@ import Prelude import Command.Docs.Html (asHtml, writeHtmlModules) import Command.Docs.Markdown (asMarkdown, writeMarkdownModules) import Control.Applicative (Alternative(..), optional) -import Control.Monad.Writer (when) +import Control.Monad (when) import Control.Monad.Trans.Except (runExceptT) import Data.Maybe (fromMaybe) import Data.Text qualified as T diff --git a/app/Command/Docs/Html.hs b/app/Command/Docs/Html.hs index 6ad51041f3..116cf0f7a7 100644 --- a/app/Command/Docs/Html.hs +++ b/app/Command/Docs/Html.hs @@ -9,7 +9,7 @@ import Prelude import Control.Applicative (Alternative(..)) import Control.Arrow ((&&&)) -import Control.Monad.Writer (guard) +import Control.Monad (guard) import Data.List (sort) import Data.Text (Text) import Data.Text.Lazy (toStrict) diff --git a/src/Control/Monad/Supply.hs b/src/Control/Monad/Supply.hs index 8c64fd2524..dd447a9c39 100644 --- a/src/Control/Monad/Supply.hs +++ b/src/Control/Monad/Supply.hs @@ -7,7 +7,8 @@ import Prelude import Control.Applicative (Alternative) import Control.Monad.Error.Class (MonadError(..)) -import Control.Monad.Reader (MonadPlus, MonadReader, MonadTrans) +import Control.Monad.Reader (MonadReader, MonadTrans) +import Control.Monad (MonadPlus) import Control.Monad.State (StateT(..)) import Control.Monad.Writer (MonadWriter) diff --git a/src/Language/PureScript/Errors.hs b/src/Language/PureScript/Errors.hs index 56d962b3c7..6a15c3690c 100644 --- a/src/Language/PureScript/Errors.hs +++ b/src/Language/PureScript/Errors.hs @@ -13,7 +13,8 @@ import Control.Lens (both, head1, over) import Control.Monad (forM, unless) import Control.Monad.Error.Class (MonadError(..)) import Control.Monad.Trans.State.Lazy (State, evalState, get, put) -import Control.Monad.Writer (Last(..), MonadWriter(..), censor) +import Control.Monad.Writer (MonadWriter(..), censor) +import Data.Monoid (Last(..)) import Data.Bifunctor (first, second) import Data.Bitraversable (bitraverse) import Data.Char (isSpace) diff --git a/src/Language/PureScript/Renamer.hs b/src/Language/PureScript/Renamer.hs index a54e39f1e1..aff42ca288 100644 --- a/src/Language/PureScript/Renamer.hs +++ b/src/Language/PureScript/Renamer.hs @@ -5,7 +5,8 @@ module Language.PureScript.Renamer (renameInModule) where import Prelude -import Control.Monad.State (MonadState(..), State, gets, modify, runState, (>=>)) +import Control.Monad.State (MonadState(..), State, gets, modify, runState) +import Control.Monad ((>=>)) import Data.Functor ((<&>)) import Data.List (find) diff --git a/src/Language/PureScript/Sugar/Operators/Common.hs b/src/Language/PureScript/Sugar/Operators/Common.hs index 1a18f88014..7fd6df9645 100644 --- a/src/Language/PureScript/Sugar/Operators/Common.hs +++ b/src/Language/PureScript/Sugar/Operators/Common.hs @@ -2,7 +2,7 @@ module Language.PureScript.Sugar.Operators.Common where import Prelude -import Control.Monad.State (guard, join) +import Control.Monad (guard, join) import Control.Monad.Except (MonadError(..)) import Data.Either (rights) diff --git a/src/Language/PureScript/TypeChecker/Entailment.hs b/src/Language/PureScript/TypeChecker/Entailment.hs index 7a3872c1c8..85bdfee4aa 100644 --- a/src/Language/PureScript/TypeChecker/Entailment.hs +++ b/src/Language/PureScript/TypeChecker/Entailment.hs @@ -15,9 +15,11 @@ import Protolude (ordNub, headMay) import Control.Arrow (second, (&&&)) import Control.Monad.Error.Class (MonadError(..)) -import Control.Monad.State (MonadState(..), MonadTrans(..), StateT(..), evalStateT, execStateT, foldM, gets, guard, join, modify, zipWithM, zipWithM_, (<=<)) +import Control.Monad.State (MonadState(..), MonadTrans(..), StateT(..), evalStateT, execStateT, gets, modify) +import Control.Monad (foldM, guard, join, zipWithM, zipWithM_, (<=<)) import Control.Monad.Supply.Class (MonadSupply(..)) -import Control.Monad.Writer (Any(..), MonadWriter(..), WriterT(..)) +import Control.Monad.Writer (MonadWriter(..), WriterT(..)) +import Data.Monoid (Any(..)) import Data.Either (lefts, partitionEithers) import Data.Foldable (for_, fold, toList) diff --git a/src/Language/PureScript/TypeChecker/Monad.hs b/src/Language/PureScript/TypeChecker/Monad.hs index ba27d0299b..b6382e6707 100644 --- a/src/Language/PureScript/TypeChecker/Monad.hs +++ b/src/Language/PureScript/TypeChecker/Monad.hs @@ -9,7 +9,8 @@ import Prelude import Control.Arrow (second) import Control.Monad.Error.Class (MonadError(..)) -import Control.Monad.State (MonadState(..), StateT(..), forM_, gets, guard, join, modify, when, (<=<)) +import Control.Monad.State (MonadState(..), StateT(..), gets, modify) +import Control.Monad (forM_, guard, join, when, (<=<)) import Control.Monad.Writer.Class (MonadWriter(..), censor) import Data.Maybe (fromMaybe)