Skip to content

Conversation

gelisam
Copy link
Collaborator

@gelisam gelisam commented Apr 16, 2018

The pattern guard was clearly meant as a list-comprehension filter,
but on a let-bound pattern, it instead caused a circular loop in which
whether the LHS variables are bound the the RHS values depends on the
values of the LHS variables.

fixes #5081


Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

I tested this by running the problematic command from #5081. Result before the fix:

$ cabal new-build test:unknown-test-suite
cabal: Internal error in target matching. It should always be possible to find
a syntax that's sufficiently qualified to give an unambiguous match. However
when matching 'test:unknown-test-suite' we found test:unknown-test-suite
(unknown-component) which does not have an unambiguous syntax. The possible
syntax and the targets they match are as follows:
cabal: <<loop>>

Result after the fix:

$ cabal new-build test:unknown-test-suite
cabal: Internal error in target matching. It should always be possible
to find a syntax that's sufficiently qualified to give an unambiguous match.
However when matching 'test:unknown-test-suite' we found
test:unknown-test-suite (unknown-component) which does not have an unambiguous
syntax. The possible syntax and the targets they match are as follows:
'test:unknown-test-suite' which matches test:unknown-test-suite
(unknown-component), :pkg:test:lib:test:file:unknown-test-suite (unknown-file)

I also tested with all:test (typo for all:tests), which has similar results before and after the fix.

The pattern guard was clearly meant as a list-comprehension filter,
but on a let-bound pattern, it instead caused a circular loop in which
whether the LHS variables are bound the the RHS values depends on the
values of the LHS variables.

fixes #5081
@gelisam gelisam requested a review from dcoutts April 16, 2018 03:17
@alexbiehl
Copy link
Member

This looks good to me! Let's merge this!

@23Skidoo 23Skidoo merged commit c151e02 into master Apr 18, 2018
@23Skidoo 23Skidoo deleted the target-selector-loop branch April 18, 2018 07:54
@23Skidoo
Copy link
Member

Merged, thanks!

23Skidoo added a commit that referenced this pull request Apr 18, 2018
fix infinite loop in D.Client.TargetSelector

(cherry picked from commit c151e02)
@23Skidoo
Copy link
Member

Also cherry-picked into 2.2.

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

Successfully merging this pull request may close these issues.

"cabal: Internal error in target matching" (was: Internal error/infinite loop in D.Client.TargetSelector)
3 participants