-
6e67fa08
by Ben Gamari at 2025-05-08T06:21:21-04:00
llvmGen: Fix built-in variable predicate
Previously the predicate to identify LLVM builtin global variables was
checking for `$llvm` rather than `@llvm` as it should.
-
a9d0a22c
by Ben Gamari at 2025-05-08T06:21:22-04:00
llvmGen: Fix linkage of built-in arrays
LLVM now insists that built-in arrays use Appending linkage, not
Internal.
Fixes #25769.
-
9c6d2b1b
by sheaf at 2025-05-08T06:22:11-04:00
Use mkTrAppChecked in ds_ev_typeable
This change avoids violating the invariant of mkTrApp according to which
the argument should not be a fully saturated function type.
This ensures we don't return false negatives for type equality
involving function types.
Fixes #25998
-
75cadf81
by Ryan Hendrickson at 2025-05-08T06:22:55-04:00
haddock: Preserve indentation in multiline examples
Intended for use with :{ :}, but doesn't look for those characters. Any
consecutive lines with birdtracks will only have initial whitespace
stripped up to the column of the first line.
-
fee9b351
by Cheng Shao at 2025-05-08T06:23:36-04:00
ci: re-enable chrome for wasm ghci browser tests
Currently only firefox is enabled for wasm ghci browser tests, for
some reason testing with chrome works on my machine but gets stuck on
gitlab instance runners. This patch re-enables testing with chrome by
passing `--no-sandbox`, since chrome sandboxing doesn't work in
containers without `--cap-add=SYS_ADMIN`.
-
282df905
by Vladislav Zavialov at 2025-05-09T03:18:25-04:00
Take subordinate 'type' specifiers into account
This patch fixes multiple bugs (#22581, #25983, #25984, #25991)
in name resolution of subordinate import lists.
Bug #22581
----------
In subordinate import lists, the use of the `type` namespace specifier
used to be ignored. For example, this import statement was incorrectly
accepted:
import Prelude (Bool(type True))
Now it results in an error message:
<interactive>:2:17: error: [GHC-51433]
In the import of ‘Prelude’:
a data type called ‘Bool’ is exported,
but its subordinate item ‘True’ is not in the type namespace.
Bug #25983
----------
In subordinate import lists within a `hiding` clause, non-existent
items led to a poor warning message with -Wdodgy-imports. Consider:
import Prelude hiding (Bool(X))
The warning message for this import statement used to misreport the
cause of the problem:
<interactive>:3:24: warning: [GHC-56449] [-Wdodgy-imports]
In the import of ‘Prelude’:
an item called ‘Bool’ is exported, but it is a type.
Now the warning message is correct:
<interactive>:2:24: warning: [GHC-10237] [-Wdodgy-imports]
In the import of ‘Prelude’:
a data type called ‘Bool’ is exported, but it does not export
any constructors or record fields called ‘X’.
Bug #25984
----------
In subordinate import lists within a `hiding` clause, non-existent
items resulted in the entire import declaration being discarded.
For example, this program was incorrectly accepted:
import Prelude hiding (Bool(True,X))
t = True
Now it results in an error message:
<interactive>:2:5: error: [GHC-88464]
Data constructor not in scope: True
Bug #25991
----------
In subordinate import lists, it was not possible to refer to a class
method if there was an associated type of the same name:
module M_helper where
class C a b where
type a # b
(#) :: a -> b -> ()
module M where
import M_helper (C((#)))
This import declaration failed with:
M.hs:2:28: error: [GHC-10237]
In the import of ‘M_helper’:
an item called ‘C’ is exported, but it does not export any children
(constructors, class methods or field names) called ‘#’.
Now it is accepted.
Summary
-------
The changes required to fix these bugs are almost entirely confined to
GHC.Rename.Names. Other than that, there is a new error constructor
BadImportNonTypeSubordinates with error code [GHC-51433].
Test cases:
T22581a T22581b T22581c T22581d
T25983a T25983b T25983c T25983d T25983e T25983f T25983g
T25984a T25984b
T25991a T25991b1 T25991b2
-
51b0ce8f
by Simon Peyton Jones at 2025-05-09T03:19:07-04:00
Slighty improve `dropMisleading`
Fix #26105, by upgrading the (horrible, hacky) `dropMisleading`
function.
This fix makes things a bit better but does not cure the underlying
problem.
-
7b2d1e6d
by Simon Peyton Jones at 2025-05-11T03:24:47-04:00
Refine `noGivenNewtypeReprEqs` to account for quantified constraints
This little MR fixes #26020. We are on the edge of completeness
for newtype equalities (that doesn't change) but this MR makes GHC
a bit more consistent -- and fixes the bug reported.
-
eaa8093b
by Cheng Shao at 2025-05-11T03:25:28-04:00
wasm: mark freeJSVal as INLINE
This patch marks `freeJSVal` as `INLINE` for the wasm backend. I
noticed that the `freeJSVal` invocations are not inlined when
inspecting STG/Cmm dumps of downstream libraries that use release
build of the wasm backend. The performance benefit of inlining here is
very modest, but so is the cost anyway; if you are using `freeJSVal`
at all then you care about every potential chance to improve
performance :)
-
eac196df
by Cheng Shao at 2025-05-11T03:25:28-04:00
wasm: add zero length fast path for fromJSString
This patch adds a zero length fast path for `fromJSString`; when
marshaling a zero-length `JSString` we don't need to allocate an empty
`ByteArray#` at all.
-
008eb3de
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
GHC-CPP: first rough proof of concept
Processes
#define FOO
#ifdef FOO
x = 1
#endif
Into
[ITcppIgnored [L loc ITcppDefine]
,ITcppIgnored [L loc ITcppIfdef]
,ITvarid "x"
,ITequal
,ITinteger (IL {il_text = SourceText "1", il_neg = False, il_value = 1})
,ITcppIgnored [L loc ITcppEndif]
,ITeof]
In time, ITcppIgnored will be pushed into a comment
-
089fecc2
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
Tidy up before re-visiting the continuation mechanic
-
487bb5dc
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
Switch preprocessor to continuation passing style
Proof of concept, needs tidying up
-
7edf6c54
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
Small cleanup
-
2b817f66
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
Get rid of some cruft
-
7872e670
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
Starting to integrate.
Need to get the pragma recognised and set
-
c9e99ed8
by Alan Zimmerman at 2025-05-11T09:30:18+01:00
Make cppTokens extend to end of line, and process CPP comments
-
e923893a
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Remove unused ITcppDefined
-
e8953c29
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Allow spaces between # and keyword for preprocessor directive
-
03b42120
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Process CPP continuation lines
They are emited as separate ITcppContinue tokens.
Perhaps the processing should be more like a comment, and keep on
going to the end.
BUT, the last line needs to be slurped as a whole.
-
3a5d4b5b
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Accumulate CPP continuations, process when ready
Can be simplified further, we only need one CPP token
-
c6f6c423
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Simplify Lexer interface. Only ITcpp
We transfer directive lines through it, then parse them from scratch
in the preprocessor.
-
2401b5bd
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Deal with directive on last line, with no trailing \n
-
30c12a64
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Start parsing and processing the directives
-
c14f5912
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Prepare for processing include files
-
3f2af56b
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Move PpState into PreProcess
And initParserState, initPragState too
-
7a4c3be6
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Process nested include files
Also move PpState out of Lexer.x, so it is easy to evolve it in a ghci
session, loading utils/check-cpp/Main.hs
-
7e897990
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Split into separate files
-
908fac7f
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Starting on expression parser.
But it hangs. Time for Text.Parsec.Expr
-
83fa5e8e
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Start integrating the ghc-cpp work
From https://github.com/alanz/ghc-cpp
-
c847b2de
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
WIP
-
f80202b0
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Fixup after rebase
-
be64d7f1
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
WIP
-
62cf6dc2
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Fixup after rebase, including all tests pass
-
19f94464
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Change pragma usage to GHC_CPP from GhcCPP
-
a4bd0f40
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Some comments
-
f1e37370
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Reformat
-
ecf10594
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Delete unused file
-
ce8f468e
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Rename module Parse to ParsePP
-
ac007250
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Clarify naming in the parser
-
c46af796
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
WIP. Switching to alex/happy to be able to work in-tree
Since Parsec is not available
-
07bb0700
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Layering is now correct
- GHC lexer, emits CPP tokens
- accumulated in Preprocessor state
- Lexed by CPP lexer, CPP command extracted, tokens concated with
spaces (to get rid of token pasting via comments)
- if directive lexed and parsed by CPP lexer/parser, and evaluated
-
3df296e4
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
First example working
Loading Example1.hs into ghci, getting the right results
```
{-# LANGUAGE GHC_CPP #-}
module Example1 where
y = 3
x =
"hello"
"bye now"
foo = putStrLn x
```
-
385c2888
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Rebase, and all tests pass except whitespace for generated parser
-
c1b47276
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
More plumbing. Ready for testing tomorrow.
-
4d016ede
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Proress. Renamed module State from Types
And at first blush it seems to handle preprocessor scopes properly.
-
a9141ac0
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Insert basic GHC version macros into parser
__GLASGOW_HASKELL__
__GLASGOW_HASKELL_FULL_VERSION__
__GLASGOW_HASKELL_PATCHLEVEL1__
__GLASGOW_HASKELL_PATCHLEVEL2__
-
5531f1c4
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Re-sync check-cpp for easy ghci work
-
3cc2bd4e
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Get rid of warnings
-
1be7274c
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Rework macro processing, in check-cpp
Macros kept at the top level, looked up via name, multiple arity
versions per name can be stored
-
4d0dc3df
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
WIP. Can crack arguments for #define
Next step it to crack out args in an expansion
-
c1105237
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
WIP on arg parsing.
-
e74078ab
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Progress. Still screwing up nested parens.
-
6f9a9807
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Seems to work, but has redundant code
-
1e1ba894
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Remove redundant code
-
0cc89740
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Reformat
-
99905d3a
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Expand args, single pass
Still need to repeat until fixpoint
-
ee280b86
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Fixed point expansion
-
27dc3326
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Sync the playground to compiler
-
3f36e05b
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Working on dumping the GHC_CPP result
But We need to keep the BufSpan in a comment
-
31f8acf7
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Keep BufSpan in queued comments in GHC.Parser.Lexer
-
9f00bb84
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Getting close to being able to print the combined tokens
showing what is in and what is out
-
937f1cad
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
First implementation of dumpGhcCpp.
Example output
First dumps all macros in the state, then the source, showing which
lines are in and which are out
------------------------------
- |#define FOO(A,B) A + B
- |#define FOO(A,B,C) A + B + C
- |#if FOO(1,FOO(3,4)) == 8
- |-- a comment
|x = 1
- |#else
- |x = 5
- |#endif
-
c4e42534
by Alan Zimmerman at 2025-05-11T09:30:19+01:00
Clean up a bit
-
f00e660f
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Add -ddump-ghc-cpp option and a test based on it
-
c0fb8f3b
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Restore Lexer.x rules, we need them for continuation lines
-
51c52719
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Lexer.x: trying to sort out the span for continuations
- We need to match on \n at the end of the line
- We cannot simply back up for it
-
3d74db1e
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Inserts predefined macros. But does not dump properly
Because the cpp tokens have a trailing newline
-
4854e15c
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Remove unnecessary LExer rules
We *need* the ones that explicitly match to the end of the line.
-
0598acda
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Generate correct span for ITcpp
Dump now works, except we do not render trailing `\` for continuation
lines. This is good enough for use in test output.
-
ac7056c9
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Reduce duplication in lexer
-
f94b148f
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Tweaks
-
11db3544
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Insert min_version predefined macros into state
The mechanism now works. Still need to flesh out the full set.
-
e0537f87
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Trying my alternative pragma syntax.
It works, but dumpGhcCpp is broken, I suspect from the ITcpp token
span update.
-
733e5446
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Pragma extraction now works, with both CPP and GHC_CPP
For the following
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 913
{-# LANGUAGE GHC_CPP #-}
#endif
We will enable GHC_CPP only
-
a5b497a1
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Remove some tracing
-
c1b9796b
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Fix test exes for changes
-
39db0c54
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
For GHC_CPP tests, normalise config-time-based macros
-
ee536446
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
WIP
-
8d02ff91
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
WIP again. What is wrong?
-
caff8432
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Revert to dynflags for normal not pragma lexing
-
420cf30d
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Working on getting check-exact to work properly
-
aa3a61d5
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Passes CppCommentPlacement test
-
da700f62
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Starting on exact printing with GHC_CPP
While overriding normal CPP
-
ce00b179
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Correctly store CPP ignored tokens as comments
By populating the lexeme string in it, based on the bufpos
-
48613a46
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
WIP
-
326f58e2
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Simplifying
-
e12eeea5
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Update the active state logic
-
4be12ac8
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Work the new logic into the mainline code
-
7cb2c546
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Process `defined` operator
-
e6d72e33
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Manage lexer state while skipping tokens
There is very intricate layout-related state used when lexing. If a
CPP directive blanks out some tokens, store this state when the
blanking starts, and restore it when they are no longer being blanked.
-
81f0e39f
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Track the last token buffer index, for ITCppIgnored
We need to attach the source being skipped in an ITCppIgnored token.
We cannot simply use its BufSpan as an index into the underlying
StringBuffer as it counts unicode chars, not bytes.
So we update the lexer state to store the starting StringBuffer
location for the last token, and use the already-stored length to
extract the correct portion of the StringBuffer being parsed.
-
6cd60370
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Process the ! operator in GHC_CPP expressions
-
a9f55ef1
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Predefine a constant when GHC_CPP is being used.
-
d66895bb
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
WIP
-
893fe7e8
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Skip lines directly in the lexer when required
-
485bd931
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Properly manage location when accepting tokens again
-
9f1e0e78
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Seems to be working now, for Example9
-
9129fc9e
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Remove tracing
-
1cda94e9
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Fix parsing '*' in block comments
Instead of replacing them with '-'
-
42c0f5c6
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Keep the trailing backslash in a ITcpp token
-
ca065fe7
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Deal with only enabling one section of a group.
A group is an instance of a conditional introduced by
#if/#ifdef/#ifndef,
and ending at the final #endif, including intermediate #elsif sections
-
ec5e5d9a
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Replace remaining identifiers with 0 when evaluating
As per the spec
-
16a3908a
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Snapshot before rebase
-
1f878dce
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Skip non-processed lines starting with #
-
866ab090
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Export generateMacros so we can use it in ghc-exactprint
-
b8968c02
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Fix rebase
-
4ef7596b
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Expose initParserStateWithMacrosString
-
6d85adee
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Fix buggy lexer cppSkip
It was skipping all lines, not just ones prefixed by #
-
092d9478
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Fix evaluation of && to use the correct operator
-
ea28b177
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Deal with closing #-} at the start of a line
-
27a03123
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Add the MIN_VERSION_GLASGOW_HASKELL predefined macro
-
336c303d
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Include MIN_VERSION_GLASGOW_HASKELL in GhcCpp01.stderr
-
83a99fb9
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Use a strict map for macro defines
-
2470a576
by Alan Zimmerman at 2025-05-11T09:30:20+01:00
Process TIdentifierLParen
Which only matters at the start of #define
-
f0ffd752
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Do not provide TIdentifierLParen paren twice
-
dfe67b55
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Handle whitespace between identifier and '(' for directive only
-
dac83d3c
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Expose some Lexer bitmap manipulation helpers
-
14d82809
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Deal with line pragmas as tokens
Blows up for dumpGhcCpp though
-
d7656b21
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Allow strings delimited by a single quote too
-
a6e20292
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Allow leading whitespace on cpp directives
As per https://timsong-cpp.github.io/cppwp/n4140/cpp#1
-
9d3ffcb9
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Implement GHC_CPP undef
-
76b1f70b
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Sort out expansion of no-arg macros, in a context with args
And make the expansion bottom out, in the case of recursion
-
c6fcc93f
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Fix GhcCpp01 test
The LINE pragma stuff works in ghc-exactprint when specifically
setting flag to emit ITline_pragma tokens
-
315240e0
by Alan Zimmerman at 2025-05-11T09:30:21+01:00
Process comments in CPP directives