Ticket #2947 (closed bug: fixed)

Opened 4 years ago

Last modified 13 months ago

infix precedence of backtick functions defined in ghci is not reported by :info

Reported by: EyalLotem Owned by: pcapriotti
Priority: lowest Milestone: 7.6.1
Component: GHCi Version: 6.10.1
Keywords: Cc: anacrolix@…, daniel@…, chaddai.fouche@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

excerpt from ghci:

Prelude> let infixr 9 `f` ; f = (+)
let infixr 9 `f` ; f = (+)
Prelude> 5 * 3 `f` 4
35
Prelude> :info f
f :: Integer -> Integer -> Integer
  	-- Defined at <interactive>:1:19
Prelude> :info `f`
f :: Integer -> Integer -> Integer
  	-- Defined at <interactive>:1:19

Attachments

2947.patch Download (9.5 KB) - added by pcapriotti 14 months ago.

Change History

Changed 4 years ago by EyalLotem

In fact, the bug is more severe, the infix declaration in ghci is not used at all:

Prelude> let infixr 0 `f` ; f = (*)
let infixr 0 `f` ; f = (*)
Prelude> 5 `f` 3 + 4
19
Prelude> :info `f`
f :: Integer -> Integer -> Integer
  	-- Defined at <interactive>:1:19

Changed 4 years ago by EyalLotem

  • severity changed from minor to normal

Changed 4 years ago by simonpj

  • difficulty set to Unknown

Good point. Based on a quick look at the code, it looks as if we simply ignore fixities in let-bound definitions in GHCi.

Fixing this would not be too hard; it's just a question of adding a FixityEnv to InteractiveContext and plumbing it around. Volunteers?

Let's also see if anyone else cares. (An alternative would be simply to warn that the fixity is ignored.)

Simon

Changed 4 years ago by igloo

  • milestone set to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 21 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 20 months ago by anacrolix

  • cc anacrolix@… added
  • failure set to None/Unknown

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 16 months ago by dmwit

  • cc daniel@… added

Changed 16 months ago by Jedai

  • cc chaddai.fouche@… added

Note that this doesn't only concern backtick functions, but also operators. This is surprising but not really vital (one can always use parenthesis) so maybe a simple warning would be sufficient at least at first.

Changed 14 months ago by pcapriotti

  • owner set to pcapriotti

Changed 14 months ago by pcapriotti

Changed 14 months ago by pcapriotti

  • status changed from new to patch

Added patch.

Changed 14 months ago by simonmar

Patch looks ok to me.

Changed 13 months ago by p.capriotti@…

commit 215c8265e72a7f2a8d57793d5a5dec4c0deed08a

Author: Paolo Capriotti <p.capriotti@gmail.com>
Date:   Wed May 2 19:22:10 2012 +0100

    Add a fixity environment to InteractiveContext (#2947)

 compiler/main/HscMain.hs          |    8 ++++----
 compiler/main/HscTypes.lhs        |    4 ++++
 compiler/main/InteractiveEval.hs  |   17 ++++++++++++++---
 compiler/typecheck/TcRnDriver.lhs |   29 +++++++++++++++++------------
 4 files changed, 39 insertions(+), 19 deletions(-)

Changed 13 months ago by pcapriotti

  • status changed from patch to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.