Skip to content
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

Incorrect shadowed name warning #1406

Closed
erikd opened this issue Jun 10, 2022 · 7 comments · Fixed by #1407
Closed

Incorrect shadowed name warning #1406

erikd opened this issue Jun 10, 2022 · 7 comments · Fixed by #1407
Labels

Comments

@erikd
Copy link
Contributor

erikd commented Jun 10, 2022

For a trivial schema definition (with persistent 2.14.0.1):

share
  [ mkPersist sqlSettings
  , mkMigrate "migrateCardanoDb"
  , mkEntityDefList "entityDefs"
  , deriveShowFields
  ]
  [persistLowerCase|

  SchemaVersion
    stageOne Int
    stageTwo Int
    stageThree Int
    deriving Eq
  |]

I an getting strange shadowed name warnings like:

rc/Cardano/Db/Schema.hs:47:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘schemaVersionStageTwo’ shadows the existing binding
      defined at src/Cardano/Db/Schema.hs:47:1
   |
47 | share
   | ^^^^^...

src/Cardano/Db/Schema.hs:47:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘schemaVersionStageThree’ shadows the existing binding
      defined at src/Cardano/Db/Schema.hs:47:1
   |
47 | share
   | ^^^^^...

src/Cardano/Db/Schema.hs:47:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘schemaVersionStageOne’ shadows the existing binding
      defined at src/Cardano/Db/Schema.hs:47:1
   |
47 | share
   | ^^^^^...

src/Cardano/Db/Schema.hs:47:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘schemaVersionStageThree’ shadows the existing binding
      defined at src/Cardano/Db/Schema.hs:47:1
   |
47 | share
   | ^^^^^...

src/Cardano/Db/Schema.hs:47:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘schemaVersionStageOne’ shadows the existing binding
      defined at src/Cardano/Db/Schema.hs:47:1
   |
47 | share
   | ^^^^^...

src/Cardano/Db/Schema.hs:47:1: error: [-Wname-shadowing, -Werror=name-shadowing]
    This binding for ‘schemaVersionStageTwo’ shadows the existing binding
      defined at src/Cardano/Db/Schema.hs:47:1
   |
47 | share
   | ^^^^^...

This worked up until version 2.14. Adding the constraint persistent < 2.13.3.4 makes it build again.

@erikd
Copy link
Contributor Author

erikd commented Jun 10, 2022

I suspect this is related to #1379 but I am not sure of the fix.

@parsonsmatt
Copy link
Collaborator

Good find, thanks for reporting! I'll dig into this

parsonsmatt added a commit that referenced this issue Jun 10, 2022
* Fix a name shadowing warning

* stylish

* changelog
@parsonsmatt
Copy link
Collaborator

Released in 2.14.0.2

@brandonchinn178
Copy link
Contributor

FYI For people looking at this after the fact, the bug was introduced in 2.13.3.4

@merijn
Copy link
Contributor

merijn commented Jan 31, 2023

I think there was a regression or incomplete fix, because I'm seeing this exact same error and same cause (duplicated names in patterns) on 2.14.4, example generated code obtained via dump-splices:

      Database.Persist.Class.PersistEntity.keyFromRecordM
        = Just
            (\ StepPropValue {stepPropValueVariantId = stepPropValueVariantId,
                              stepPropValueStepId = stepPropValueStepId,
                              stepPropValueProperty = stepPropValueProperty}
               -> ((StepPropValueKey stepPropValueVariantId) stepPropValueStepId)
                    stepPropValueProperty)

@merijn
Copy link
Contributor

merijn commented Jan 31, 2023

I suspect #1460 is too blame, because the code for that fix touches the same code that was touched by this fix?

@merijn
Copy link
Contributor

merijn commented Jan 31, 2023

Nevermind, 2.14.4.3 has the same issue for me, so it's not #1460 and possibly the original problem wasn't completely fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants