haskell.tmbundle
haskell.tmbundle copied to clipboard
pragma within block comment isn't recognized, causes comment to end abruptly
The following comment can be found in GHC at compiler/GHC/StgToCmm/Expr.hs:
{-
Note [Scrutinising VoidRep]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Suppose we have this STG code:
f = \[s : State# RealWorld] ->
case s of _ -> blah
This is very odd. Why are we scrutinising a state token? But it
can arise with bizarre NOINLINE pragmas (#9964)
crash :: IO ()
crash = IO (\s -> let {-# NOINLINE s' #-}
s' = s
in (# s', () #))
Now the trouble is that 's' has VoidRep, and we do not bind void
arguments in the environment; they don't live anywhere. See the
calls to nonVoidIds in various places. So we must not look up
's' in the environment. Instead, just evaluate the RHS! Simple.
-}
Following the rules in the Haskell.plist syntax grammar, the beginning of {-# NOINLINE s' #-} is not matched as a comment (since it is followed by #), but the end is. This causes the comment to end abruptly.
The following diff fixes the issue for me. Let me know if you'd like a pull request.
400c400,416
< <string>#block_comment</string>
---
> <string>#nested_block_comment</string>
> </dict>
> </array>
> </dict>
> <key>nested_block_comment</key>
> <dict>
> <key>applyEndPatternLast</key>
> <integer>1</integer>
> <key>begin</key>
> <string>\{-</string>
> <key>end</key>
> <string>-\}</string>
> <key>patterns</key>
> <array>
> <dict>
> <key>include</key>
> <string>#nested_block_comment</string>