Skip to content
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

pragma within block comment isn't recognized, causes comment to end abruptly #23

Open
ianh opened this issue Jun 30, 2021 · 1 comment

Comments

@ianh
Copy link

ianh commented Jun 30, 2021

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.

@ianh
Copy link
Author

ianh commented Jun 30, 2021

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant