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

Fix --repl-options parsing #7868

Merged
merged 1 commit into from
Dec 22, 2021
Merged

Fix --repl-options parsing #7868

merged 1 commit into from
Dec 22, 2021

Conversation

bacchanalia
Copy link
Collaborator

Bug #7867

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the standalone fix, it would need a regression test, but if you have tested manually and it is included in your main pr in some way it would be fine for me.
A changelog entry would be great.

@jneira
Copy link
Member

jneira commented Dec 13, 2021

As noted by @bacchanalia the bug is not in any release so the changelog would not be needed and the main pr is already testing it, could you add a brief note about what test is and how is testing the bug?

@bacchanalia
Copy link
Collaborator Author

In the latest design of #7851, I use replOptionsFlags to pass the script location between cabal-install and Cabal, so either cabal-testsuite/PackageTests/NewBuild/CmdRepl/Script or cabal-testsuite/PackageTests/NewBuild/CmdRepl/ScriptRerun would catch it because the repl would fail to load from the script file being passed multiple times.

@jneira jneira linked an issue Dec 13, 2021 that may be closed by this pull request
@jneira
Copy link
Member

jneira commented Dec 13, 2021

The pr (#7578) by @sirlensalot had specific tests so i hope this change will not break the functionality added there. I would ask the pr author to take a look and confirm it, thanks!

Copy link
Member

@jneira jneira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me given the notes about the changelog and tests, thanks for the fix!

@Mikolaj
Copy link
Member

Mikolaj commented Dec 13, 2021

I think the backport of this bug is in 3.6.2 (#7593), ain't it so?

@jneira
Copy link
Member

jneira commented Dec 13, 2021

it seems #7593 was closed wisely by @fgaz without merging it

@Mikolaj
Copy link
Member

Mikolaj commented Dec 13, 2021

Wow, I missed it. Well done, team. :)

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super.

@jneira
Copy link
Member

jneira commented Dec 13, 2021

no need for backport then (i was not sure if the bug was backported after the release so thanks for link the closed backport)

i would wait some time for the review of the original pr author before merging

@fgaz fgaz added the 3.8 label Dec 13, 2021
@sergv
Copy link
Collaborator

sergv commented Dec 22, 2021

Although I'm not the original author, I can confirm that the commit is correct. I did encounter this problem myself and did a bit of investigation.

The original commit (cf 785ea62#diff-793c63febac9c808425678cd5535233aebb1aca838a829a665f85d4452f62346L1766) did the following change


-replOptions :: ShowOrParseArgs -> [OptionField [String]]
-replOptions _ = [ option [] ["repl-options"] "use this option for the repl" id
-              const (reqArg "FLAG" (succeedReadE (:[])) id) ]
+replOptions :: ShowOrParseArgs -> [OptionField ReplOptions]
+replOptions _ =
+  [ option [] ["repl-no-load"]
+    "Disable loading of project modules at REPL startup."
+    replOptionsNoLoad (\p flags -> flags { replOptionsNoLoad = p })
+    trueArg
+  , option [] ["repl-options"]
+    "use this option for the repl"
+    replOptionsFlags (\p flags -> flags { replOptionsFlags = p ++ replOptionsFlags flags })
+    (reqArg "FLAG" (succeedReadE (:[])) id)
+  ]

Note that what previously was id and const now became replOptionsFlags and a lambda (\p flags -> ...). This is a getter and setter pair however previously the setter was not updating the old flags value. That's because ultimately during option parsing the appending of options will take place at https://github.com/haskell/cabal/blob/master/Cabal/src/Distribution/Simple/Command.hs#L159 (notice the mappend).

So the short summary is that previously there were no ++ and it shouldn't have been added in the 785ea62 commit.

@Mikolaj
Copy link
Member

Mikolaj commented Dec 22, 2021

@sergv: thank you for the analysis and confirmation. I think the merge is overdue. Thank you all!

@Mikolaj Mikolaj added the merge me Tell Mergify Bot to merge label Dec 22, 2021
@mergify mergify bot merged commit 9516034 into haskell:master Dec 22, 2021
@sirlensalot
Copy link
Collaborator

Sorry for the delay responding, but obviously I concur with it as the author of the bug! Clearly my tests didn't catch this.

Indeed my only comment would have been: coverage? Can we get the bugfix covered by a unit test. I wrote a test for my functionality, which clearly didn't cover so I'm assuming this broke other workflows. Can we get coverage for those in a follow-on PR please?

@sirlensalot
Copy link
Collaborator

Happy to help if somebody can give the use-case clearly

@bacchanalia
Copy link
Collaborator Author

I though this would be covered by the tests in the other PR (#7851) I was working on, but due to code changes in that pr the tests no longer cover this, so we do still need tests for it.

@bacchanalia bacchanalia deleted the 7867 branch January 28, 2022 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: needs-review merge me Tell Mergify Bot to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

super-exponential explosion of --repl-options
6 participants