Skip to content

Add language extension code action targets the nearest {-# pragma #1958

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

Closed
isovector opened this issue Jun 22, 2021 · 4 comments
Closed

Add language extension code action targets the nearest {-# pragma #1958

isovector opened this issue Jun 22, 2021 · 4 comments
Labels
component: hls-pragmas-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@isovector
Copy link
Collaborator

Given this:

data Metaprogram = Metaprogram
  { mp_name             :: !Text
  , mp_known_by_auto    :: !Bool
  , mp_show_code_action :: !Bool
  , mp_program          :: !(TacticsM ())
  }
  deriving stock Generic
{-# ANN Metaprogram "hello" #-}

instance NFData Metaprogram where
  rnf (!(Metaprogram !_ !_ !_ !_)) = ()

without -XBangPatterns enabled, I get a code action on the last line, suggesting I add BangPatterns. Doing so produces this output:

data Metaprogram = Metaprogram
  { mp_name             :: !Text
  , mp_known_by_auto    :: !Bool
  , mp_show_code_action :: !Bool
  , mp_program          :: !(TacticsM ())
  }
  deriving stock Generic
{-# ANN Metaprogram "hello" #-}
{-# LANGUAGE BangPatterns #-}

instance NFData Metaprogram where
  rnf (!(Metaprogram !_ !_ !_ !_)) = ()

which is super the wrong place for it.

@isovector isovector added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: ghcide labels Jun 22, 2021
@isovector
Copy link
Collaborator Author

Also happens with INLINE pragmas

@Ailrun
Copy link
Member

Ailrun commented Jun 22, 2021

line = maybe 0 succ (lastLineWithPrefix "{-#" <|> lastLineWithPrefix "#!")

is the line causing the problem.

@jneira
Copy link
Member

jneira commented Jun 22, 2021

pragmas plugin is having a hard time finding the correct place to add the extension 😄
we must add a regression test for this (and over whatever corner case we can think of!)

@jneira
Copy link
Member

jneira commented Aug 16, 2021

This was closed by #2043 i suppose, closing optimistically

@jneira jneira closed this as completed Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-pragmas-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants