[GHC] #15730: SCC/HPC/CORE annotation can change the meaning of an expression

#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect result Unknown/Multiple | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider this GHCi session: {{{ Prelude> 1 / 2 / 2 0.25 Prelude> 1 / {-# SCC ann #-} 2 / 2 1.0 }}} Adding an SCC annotation changed the meaning of the expression. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by int-index): This is a parsing issue. The first expression is parsed as `(1 / 2) / 2`, while the second as `1 / (2 / 2)`. I plan to fix by changing the precedence of the pragma. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5218 Wiki Page: | -------------------------------------+------------------------------------- Changes (by int-index): * status: new => patch * differential: => Phab:D5218 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5218 Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): Thanks for the patch. I added a comment there. In short, this is not a bug, you just need to know that annotations have lower precedence that everything else. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5218 Wiki Page: | -------------------------------------+------------------------------------- Comment (by int-index):
In short, this is not a bug, you just need to know that annotations have lower precedence that everything else.
Adding an annotation should not change the parse tree in any way other than adding an annotation to a node. I am firm in this expectation. "You just have to know there's a bug" is still a bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Adding an annotation should not change the parse tree in any way other
#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5218 Wiki Page: | -------------------------------------+------------------------------------- Comment (by osa1): than adding an annotation to a node You're assuming that in {{{ {-# SCC foo #-} f x y }}} the node you're annotating is `f` and not `f x y`. I don't know why this is better or more reasonable than the current behavior. Either way, as said in the diff, you need a proposal for this as this is a breaking change of a user-facing behavior. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Adding an annotation should not change the parse tree in any way other
#15730: SCC/HPC/CORE annotation can change the meaning of an expression -------------------------------------+------------------------------------- Reporter: int-index | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: Component: Compiler | Version: 8.6.1 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5218 Wiki Page: | -------------------------------------+------------------------------------- Comment (by int-index): Replying to [comment:5 osa1]: than adding an annotation to a node
You're assuming that in
{{{ {-# SCC foo #-} f x y }}}
the node you're annotating is `f` and not `f x y`. I don't know why this
is better or more reasonable than the current behavior.
I'm not assuming this. In the patch that I offered, it is still parsed as `{-# SCC foo #-} f x y`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15730#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC