-
Notifications
You must be signed in to change notification settings - Fork 81
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
Guess that TypeApplications is used without being enabled #452
Comments
I don't understand how this is going on work. If |
Yes, you don't get it parsed as a type application, you get it parsed as an as-pattern. The AST is not well-typed enough, so it does not prohibit as-patterns in expression context. |
https://gitlab.haskell.org/ghc/ghc/wikis/design/exp-pat-frame
|
What if it was a genuine "at pattern"? |
In In
|
We already have a comment there: -- These four constructs should never appear in correct programs.
-- See: https://github.com/tweag/ormolu/issues/343
EWildPat NoExt -> txt "_"
EAsPat NoExt n p -> do
p_rdrName n
txt "@"
located p p_hsExpr
EViewPat NoExt p e -> do
located p p_hsExpr
space
txt "->"
breakpoint
inci (located e p_hsExpr)
ELazyPat NoExt p -> do
txt "~"
located p p_hsExpr Btw, I believe we can error out on Regarding #343, I believe that it should be fixed now that |
Actually, it has just occurred to me – what syntax does TypeApplications, -- steals (@) operator on some cases but it doesn't seem to steal that operator: main = main
where
(@) = (+)
It also isn't mentioned in the summary of stolen syntax. Perhaps we should just enable it by default? |
Oh damn, found it: {-# LANGUAGE TypeApplications #-}
main = case [1] of
xs @ (x:_) -> print (x, xs)
xs@[] -> print xs
|
What do you mean by "error out"? Can you describe the whole plan step by step? I still do not understand what you want to implement, sorry. I'd like to have clear description of problem you want to solve and then your proposed solution.
No, I remember this wasn't enabled at first and we found a failing case. @utdemir may remember what exactly. |
The problem is that currently, when a user formats |
@neongreen Thanks. Now it's clear. I'd be OK with a PR for this. |
Just to be clear, do you mean a PR adding |
Just enabling it by default is will break things because it steals syntax. There should be something more clever, ask @neongreen, because I have forgotten and it's not obvious from skimming the thread. |
I proposed guessing that I am not going to implement this myself, though. |
Most likely, this issue can be closed as soon as ghc-lib-parser-9.0 is used, namely due to the new whitespace-sensitivity of main = case [1] of
xs @ (x:_) -> print (x, xs)
xs@[] -> print xs from above will fail to parse even without TypeApplications being enabled:
With ghc-lib-parser-9.0, I can't think of an example where enabling/disabling TypeApplications would make any difference (please mention it here if you find one!), so we will be able to enable TypeApplications by default in the next release! |
Previous version built on GHC 8.10.7, which seems to have some issue with TypeApplications. (Probably related to tweag/ormolu#452)
Since we don't have #56, people who have
TypeApplications
in their default-extensions get theirf @Foo
turned silently intof@Foo
.We can detect this by spotting
EAsPat
when rendering expressions and erroring out.The text was updated successfully, but these errors were encountered: