-
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
Document GHC-12219: static forms cannot be used in splices #494
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: static forms cannot be used in splices | ||
summary: Static forms are disallowed in splices | ||
severity: error | ||
introduced: 9.6.1 | ||
--- | ||
|
||
``` | ||
static.hs:7:45: error: [GHC-12219] | ||
• static forms cannot be used in splices: static 'a' | ||
• In the untyped splice: $(lift (show $ staticKey $ static 'a')) | ||
``` | ||
|
||
GHC does not support using a static form in a splice, i.e. obtaining a reference | ||
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. I appreciate that it's tedious, but IMHO it's worth to provide readers with more context, especially when it comes to rare features of the language. Those who are already in the know what is a static form and what is a splice are not our target audience. For someone who encountered the error just by making a typo it would help to know which language extensions are involved and have a link to the GHC manual at ready. I'd suggest to spell out "TemplateHaskell splices" in full, to make it unambiguous. |
||
to a `StaticPtr` at compile time |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{-# LANGUAGE StaticPointers #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
module StaticSplice where | ||
|
||
import GHC.StaticPtr | ||
import Language.Haskell.TH.Syntax | ||
|
||
main = print $([| show $ staticKey $ static 'a' |]) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{-# LANGUAGE StaticPointers #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module StaticSplice where | ||
|
||
import GHC.StaticPtr | ||
import Language.Haskell.TH.Syntax | ||
|
||
main = print =<< $(lift (show $ staticKey $ static 'a') ) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: GHC does not support defining static pointers in splices | ||
--- | ||
|
||
You can't use a static forms in a splice - i.e. you can't obtain a `StaticPtr` | ||
in code that runs at compile time. | ||
|
||
Evaluating a quote that has a static form is not a problem, since this is code | ||
that will be evaluated at run time. |
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.
Even while GHC itself starts the error message from lower case, I'd prefer to keep
title
s in title case.