-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GHC-18157 #509
Open
ryndubei
wants to merge
1
commit into
haskellfoundation:main
Choose a base branch
from
ryndubei:ghc-18157
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add GHC-18157 #509
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
title: GHC stage restriction | ||
summary: A local name is used in a top-level splice, quasi-quote or annotation. | ||
severity: error | ||
introduced: 9.8.1 | ||
--- | ||
|
||
A top-level | ||
[Template Haskell splice](https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/template_haskell.html#syntax), | ||
[quasi-quote](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/template_haskell.html#template-haskell-quasi-quotation) | ||
or | ||
[source annotation](https://downloads.haskell.org/ghc/latest/docs/users_guide/extending_ghc.html#source-annotations). | ||
cannot directly call a variable bound in the same module. |
4 changes: 4 additions & 0 deletions
4
message-index/messages/GHC-18157/stage-restriction-anns/after/Bar.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Bar (bar) where | ||
|
||
bar :: Integer | ||
bar = 2 |
7 changes: 7 additions & 0 deletions
7
message-index/messages/GHC-18157/stage-restriction-anns/after/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Example where | ||
|
||
import Bar (bar) | ||
|
||
{-# ANN foo bar #-} | ||
foo :: Integer | ||
foo = 1 |
8 changes: 8 additions & 0 deletions
8
message-index/messages/GHC-18157/stage-restriction-anns/before/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Example where | ||
|
||
{-# ANN foo bar #-} | ||
foo :: Integer | ||
foo = 1 | ||
|
||
bar :: Integer | ||
bar = 2 |
17 changes: 17 additions & 0 deletions
17
message-index/messages/GHC-18157/stage-restriction-anns/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: A local name is used in an annotation. | ||
--- | ||
|
||
`foo` and `bar` are both defined in the same module, causing the error. | ||
|
||
# Error Message | ||
``` | ||
Example.hs:3:13: error: [GHC-18157] | ||
• GHC stage restriction: | ||
‘bar’ is used in a top-level splice, quasi-quote, or annotation, | ||
and must be imported, not defined locally | ||
• In the annotation: {-# ANN foo bar #-} | ||
| | ||
3 | {-# ANN foo bar #-} | ||
| ^^^ | ||
``` |
7 changes: 7 additions & 0 deletions
7
message-index/messages/GHC-18157/stage-restriction-qq/after/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{-# LANGUAGE QuasiQuotes #-} | ||
module Example where | ||
|
||
import QQ (qq) | ||
|
||
foo :: String | ||
foo = [qq|1|] | ||
12 changes: 12 additions & 0 deletions
12
message-index/messages/GHC-18157/stage-restriction-qq/after/QQ.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module QQ (qq) where | ||
|
||
import Language.Haskell.TH.Quote | ||
import Language.Haskell.TH | ||
|
||
qq :: QuasiQuoter | ||
qq = QuasiQuoter | ||
{ quoteExp = pure . LitE . StringL | ||
, quoteDec = undefined | ||
, quotePat = undefined | ||
, quoteType = undefined | ||
} |
16 changes: 16 additions & 0 deletions
16
message-index/messages/GHC-18157/stage-restriction-qq/before/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{-# LANGUAGE QuasiQuotes #-} | ||
module Example where | ||
|
||
import Language.Haskell.TH.Quote | ||
import Language.Haskell.TH | ||
|
||
qq :: QuasiQuoter | ||
qq = QuasiQuoter | ||
{ quoteExp = pure . LitE . StringL | ||
, quoteDec = undefined | ||
, quotePat = undefined | ||
, quoteType = undefined | ||
} | ||
|
||
foo :: String | ||
foo = [qq|bar|] |
17 changes: 17 additions & 0 deletions
17
message-index/messages/GHC-18157/stage-restriction-qq/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: A local name is used in a quasi-quote. | ||
--- | ||
|
||
`foo` and `qq` are both defined in the same module, causing the error. | ||
|
||
# Error Message | ||
``` | ||
Example.hs:16:7: error: [GHC-18157] | ||
• GHC stage restriction: | ||
‘qq’ is used in a top-level splice, quasi-quote, or annotation, | ||
and must be imported, not defined locally | ||
• In the quasi-quotation: [qq|bar|] | ||
| | ||
16 | foo = [qq|bar|] | ||
| ^^^^^^^^^ | ||
``` |
8 changes: 8 additions & 0 deletions
8
message-index/messages/GHC-18157/stage-restriction-splice-1/after/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module Example where | ||
|
||
import Foo (foo) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we fix the error with |
||
import Language.Haskell.TH | ||
|
||
x :: Integer | ||
x = $foo |
6 changes: 6 additions & 0 deletions
6
message-index/messages/GHC-18157/stage-restriction-splice-1/after/Foo.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Foo (foo) where | ||
|
||
import Language.Haskell.TH | ||
|
||
foo :: Q Exp | ||
foo = pure . LitE $ IntegerL 1 |
10 changes: 10 additions & 0 deletions
10
message-index/messages/GHC-18157/stage-restriction-splice-1/before/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module Example where | ||
|
||
import Language.Haskell.TH | ||
|
||
foo :: Q Exp | ||
foo = pure . LitE $ IntegerL 1 | ||
|
||
x :: Integer | ||
x = $foo |
17 changes: 17 additions & 0 deletions
17
message-index/messages/GHC-18157/stage-restriction-splice-1/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: A local name is used in a top-level splice. | ||
--- | ||
|
||
`x` and `foo` are both defined in the same module, causing the error. | ||
|
||
# Error Message | ||
``` | ||
Example.hs:10:6: error: [GHC-18157] | ||
• GHC stage restriction: | ||
‘foo’ is used in a top-level splice, quasi-quote, or annotation, | ||
and must be imported, not defined locally | ||
• In the untyped splice: $foo | ||
| | ||
10 | x = $foo | ||
| ^^^ | ||
``` |
9 changes: 9 additions & 0 deletions
9
message-index/messages/GHC-18157/stage-restriction-splice-2/after/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module Example where | ||
|
||
import TH (doSomethingWithName) | ||
|
||
foo :: Int | ||
foo = 1 | ||
|
||
doSomethingWithName 'foo |
6 changes: 6 additions & 0 deletions
6
message-index/messages/GHC-18157/stage-restriction-splice-2/after/TH.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module TH (doSomethingWithName) where | ||
|
||
import Language.Haskell.TH | ||
|
||
doSomethingWithName :: Name -> DecsQ | ||
doSomethingWithName x = pure [] |
9 changes: 9 additions & 0 deletions
9
message-index/messages/GHC-18157/stage-restriction-splice-2/before/Example.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module Example where | ||
|
||
import TH (doSomethingWith) | ||
|
||
foo :: Int | ||
foo = 1 | ||
|
||
doSomethingWith foo |
6 changes: 6 additions & 0 deletions
6
message-index/messages/GHC-18157/stage-restriction-splice-2/before/TH.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module TH (doSomethingWith) where | ||
|
||
import Language.Haskell.TH | ||
|
||
doSomethingWith :: Int -> DecsQ | ||
doSomethingWith x = pure [] |
25 changes: 25 additions & 0 deletions
25
message-index/messages/GHC-18157/stage-restriction-splice-2/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
title: A local name is used in a top-level splice as a function argument. | ||
--- | ||
|
||
The error message given by GHC is slightly misleading: you cannot pass a | ||
_variable_ bound in the same module to a top-level splice, but you can pass in | ||
just the `Name`. The name must be bound above the splice in the module file. | ||
|
||
Depending on the information you need from the variable, this can be an | ||
alternative to moving the variable binding to a different module. | ||
|
||
The syntax for the `Name` literal of a function `f` is `'f`, and the `Name` of a | ||
type `T` is `''T`. To extract information from a `Name`, see `reify` in | ||
`Language.Haskell.TH`. | ||
|
||
# Error Message | ||
``` | ||
Example.hs:9:17: error: [GHC-18157] | ||
GHC stage restriction: | ||
‘foo’ is used in a top-level splice, quasi-quote, or annotation, | ||
and must be imported, not defined locally | ||
| | ||
9 | doSomethingWith foo | ||
| ^^^ | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd imagine it should remain as in "before"?..