Built-in Natural literals in Core
Concern Raisedfe770c211631

Authored by Sylvain Henry <hsyl20@gmail.com> on Jun 15 2018, 3:23 PM.


Built-in Natural literals in Core

Add support for built-in Natural literals in Core.

  • Replace MachInt,MachWord, LitInteger, etc. with a single LitNumber constructor with a LitNumType field
  • Support built-in Natural literals
  • Add desugar warning for negative literals
  • Move Maybe(..) from GHC.Base to GHC.Maybe for module dependency reasons

This patch introduces only a few rules for Natural literals (compared
to Integer's rules). Factorization of the built-in rules for numeric
literals will be done in another patch as this one is already big to

Test Plan:

test build with integer-simple

Reviewers: hvr, bgamari, goldfire, Bodigrim, simonmar

Reviewed By: bgamari

Subscribers: phadej, simonpj, RyanGlScott, carter, hsyl20, rwbarton,

GHC Trac Issues: Trac #14170, Trac #14465

Differential Revision: https://phabricator.haskell.org/D4212

bgamari committed rGHCfe770c211631: Built-in Natural literals in Core (authored by Sylvain Henry <hsyl20@gmail.com>).Jun 15 2018, 3:23 PM
sighingnow raised a concern with this commit.Jun 18 2018, 4:28 AM
sighingnow added a subscriber: sighingnow.

After this commit, the hadrian experiences GHC panic with quickest flavour. More related discussion is here.

The panic message:

Command: _build_quickest/stage0/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-db _build_quickest/stage1/lib/package.conf.d' '-this-unit-id base-' '-package-id ghc-prim-0.5.3' '-package-id integer-simple-' '-package-id rts-1.0' -i -i_build_quickest/stage1/libraries/base/build -i_build_quickest/stage1/libraries/base/build/autogen -ilibraries/base/. -Iincludes -I_build_quickest/generated -I_build_quickest/stage1/libraries/base/build -I_build_quickest/stage1/libraries/base/build/include -Ilibraries/base/include -I/dev/shm/.x/_build_quickest/stage1/lib/x86_64-linux-ghc-8.5.20180617/rts-1.0/include -I_build_quickest/generated -optc-I_build_quickest/generated -optP-include -optP_build_quickest/stage1/libraries/base/build/autogen/cabal_macros.h -optc-fno-stack-protector -odir _build_quickest/stage1/libraries/base/build -hidir _build_quickest/stage1/libraries/base/build -stubdir _build_quickest/stage1/libraries/base/build -Wnoncanonical-monad-instances -optc-Werror=unused-but-set-variable -optc-Wno-error=inline -c libraries/base/GHC/Num.hs -o _build_quickest/stage1/libraries/base/build/GHC/Num.o -O0 -H64m -this-unit-id base -Wcompat -Wnoncanonical-monad-instances -XHaskell2010 -ghcversion-file=/dev/shm/.x/_build_quickest/generated/ghcversion.h -Wno-deprecated-flags -Wno-trustworthy-safe
Exit code: 1
ghc: panic! (the 'impossible' happened)
  (GHC version 8.5.20180617 for x86_64-unknown-linux):
	Can't use Natural in base

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug


Note that with the quickest flavour we build the stage1 package with -O0. If we rebuild the GHC/Natural.o with -O (or -O2), then build the GHC/Num.o again, the panic disappears. Haven't test with quickest flavour (-O0) with make.

More complete build log: https://travis-ci.org/snowleopard/hadrian/jobs/393259151#L4209

This commit now has outstanding concerns.Jun 18 2018, 4:28 AM

The panic only occurs with ghc-8.4.2, ghc-8.2.2 works fine.