diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2011-08-05 15:29:44 +0100 |
|---|---|---|
| committer | Simon Peyton Jones <simonpj@microsoft.com> | 2011-08-05 15:29:44 +0100 |
| commit | 46c19a89d410910bc224a4a8566e506e52b36e43 (patch) | |
| tree | 30aa396cb8ef3bc30f8bb4b17964e1c24380cd69 /compiler/hsSyn/Convert.lhs | |
| parent | d670b6f4c8981c9c39bdb604f3f56ddcf4a9afef (diff) | |
| download | haskell-46c19a89d410910bc224a4a8566e506e52b36e43.tar.gz | |
Another run at binders in Template Haskell (fixes Trac #5379)
TH quotation was using mkName rather than newName for
top-level definitions, which is plain wrong as #5379
points out.
Diffstat (limited to 'compiler/hsSyn/Convert.lhs')
| -rw-r--r-- | compiler/hsSyn/Convert.lhs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/hsSyn/Convert.lhs b/compiler/hsSyn/Convert.lhs index 7a86c8180f..158a9c73d2 100644 --- a/compiler/hsSyn/Convert.lhs +++ b/compiler/hsSyn/Convert.lhs @@ -928,7 +928,8 @@ badOcc ctxt_ns occ <+> ptext (sLit "name:") <+> quotes (text occ) thRdrName :: OccName.NameSpace -> String -> TH.NameFlavour -> RdrName --- This turns a Name into a RdrName +-- This turns a TH Name into a RdrName; used for both binders and occurrences +-- See Note [Binders in Template Haskell] -- The passed-in name space tells what the context is expecting; -- use it unless the TH name knows what name-space it comes -- from, in which case use the latter @@ -1023,7 +1024,7 @@ a) We don't want to complain about "x" being bound twice in the pattern [x1,x2] b) We don't want x3 to shadow the x1,x2 c) We *do* want 'x' (dynamically bound with mkName) to bind - to the innermost binding of "x", namely x3.. (In this + to the innermost binding of "x", namely x3. d) When pretty printing, we want to print a unique with x1,x2 etc, else they'll all print as "x" which isn't very helpful @@ -1038,7 +1039,7 @@ Achieving (a) is a bit awkward, because RdrNames arising from TH and the Unqual RdrNames that would come from a user writing \[x,x] -> blah -So in Convert (here) we translate +So in Convert.thRdrName we translate TH Name RdrName -------------------------------------------------------- NameU (arising from newName) --> Exact (Name{ System }) @@ -1063,4 +1064,4 @@ So RnEnv.newGlobalBinder we spot Exact RdrNames that wrap a non-External Name, and make an External name for. (Remember, constructors and the like need External Names.) Oddly, the *occurrences* will continue to be that (non-External) System Name, -but that will come out in the wash. +but the first sweep of the optimiser will fix that. |
