Opened 9 years ago

Last modified 3 years ago

#2896 new feature request

Warning suggestion: argument not necessarily a binary operator

Reported by: porges Owned by:
Priority: low Milestone:
Component: Compiler Version: 6.10.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


As an example:

let fn (+) = 1; fn x = 2 in fn 1

The suggested warning is that: if an argument to a function consists entirely of characters which are symbols (all isSymbol), and the type of that argument isn't (a -> b -> c), then produce a warning.

Suggested wording is something along the lines of "Warning: the argument '(+)' isn't necessarily a binary operator, although it looks like one. This may be confusing to readers of your code."

Change History (3)

comment:1 Changed 9 years ago by cjs

The issue with warnings is that there has to be a way to "fix" them: that is to say, a way to change the code to say, "yes, this is what I really want to do." An example is the warning you get for "import Foo" when you need only the instances from module Foo; you'll get a warning, but you can fix it with "import Foo ()" to explicitly declare why you're doing something.

So what does one do to the code in this case to say, "Yes, I really mean this," and shut off the warning?

comment:2 Changed 9 years ago by simonpj

difficulty: Unknown
Milestone: _|_
Priority: normallow

Also don't forget that GHC supports unary postfix operators

I can see your motivation. The benefit is small, but perceptible. However, the design is not obvious, as the comments in this ticket make clear. So I'll make it low priority for now.


comment:3 Changed 3 years ago by thomie

Type of failure: Incorrect warning at compile-time
Note: See TracTickets for help on using tickets.