Ticket #1628 (new feature request)

Opened 6 years ago

Last modified 4 months ago

warning(s) for using stolen syntax that's not currently enabled

Reported by: Isaac Dupree Owned by:
Priority: low Milestone: _|_
Component: Compiler Version: 6.6.1
Keywords: Cc: id@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Turning on -fglasgow-exts makes f x = id$x break. I propose having a flag to warn about things like this, enabled by -Wall. To be precise, "stolen syntax" is syntax that means something valid in (usually) Haskell98 and something different with some extension enabled. If there are syntax-stealing extensions implemented by other non-GHC compilers, we may want to warn about those too. (This includes all keywords, possibly other words like "forall", "exists", "family", unicode symbols for -> and others...)

If anyone actually agrees on or implements a (optional) change to unary-minus, this would subsume the warning aspects of #1318.

Change History

Changed 6 years ago by simonmar

I think you're mistaken: f x = id$x means the same with -fglasgow-exts as it does without. You need to turn on -fth (aka -XTemplateHaskell) to break it.

GHC 6.8 now has separate flags for all extensions, so -fglasgow-exts is deprecated. (or at least it probably should be). In the light of this, I don't think it would be appropriate to issue a warning about syntax stolen by an extension that you have explicitly requested with a command-line flag.

Changed 6 years ago by Isaac Dupree

Okay, so our extension-flags are saner now (meaning, in HEAD/6.8). I think Christian Maeder wanted all (at least lexer) extension-syntax to become mandated by haskell-prime in order to ensure consistency... which seems a bit harsh and unworkable to me... But, I still think some people would find it valuable to (be able to) avoid using certain extension-syntax, so that those extensions (such as -XTemplateHaskell) can be turned on and used with that code, without also having to make minor changes to that code (encouraging code sharing). (Checking this by always turning on the extension would (depending on build-system) make it more difficult to compile the code without the extension on, and equally risk being inconsistent with not-using that extension.).

If there isn't a consensus for extension-syntax being that important, maybe not in -Wall, but I know some people (possibly me) _would_ want to use this warning. (and this is just a "feature request")

Changed 6 years ago by igloo

  • milestone set to 6.1

I think this would be too large a change for the 6.8 branch.

Changed 5 years ago by Isaac Dupree

  • cc id@… added

Not a priority for me, but I'd still like to see this sometime.

Changed 5 years ago by simonpj

  • priority changed from normal to low
  • milestone changed from 6.10 branch to _|_

It's not clear what you mean here:

  • Warn about things that work fine with -XExtension, but which mean something different (or perhaps are an outright error) in Haskell 98.
  • Warn about things that are stolen by -XExtension but somehow aren't right, but would be acceptable in Haskel 98 without -XExtension.

Whichever of these you mean, it looks extremely difficult to implement. For that reason I'm moving it off the 6.10 branch. If I've misunderstood, by all means respond.

Simon

Changed 5 years ago by Isaac Dupree

I meant, when your code doesn't have -XExtension enabled, warn when the enabling of -XExtension would change/break the meaning of your code (at least on the lexical level). You're probably right that it's difficult to implement --> milestone _|_. I suppose could involve running the lexer twice with different flags and seeing if the results are the same. Maybe something more reasonable for a GHC API client to do?..

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 months ago by morabbin

  • failure set to None/Unknown

Bump; still confused after all these years.

Note: See TracTickets for help on using tickets.