Error on cabal sandbox-configure with "installed" constraint #1159

bmillwood opened this Issue Dec 24, 2012 · 3 comments

2 participants


I have the following in my .cabal/config:

constraint: template-haskell installed

When I do a cabal sandbox-init I get a cabal.sandbox.config containing the following lines:

-- inherit:
constraints: template-haskell installed

Then cabal sandbox-configure says:

cabal: Error parsing package environment file
Ambiguous parse in field 'constraints'.

With a constraint other than installed (specifying the version, for example), it works fine.

@23Skidoo 23Skidoo was assigned Dec 24, 2012
Haskell member

Thanks, will look into this.

Haskell member

Interesting: parsing "template-haskell installed" with readUserConstraint returns UserConstraintInstalled (PackageName "template-haskell"), but parsing the same string with parse returns [UserConstraintInstalled (PackageName "template-haskell"),UserConstraintFlags (PackageName "template-haskell") [(FlagName "installed",True)]].

Looks like the ambiguity was always there, and I just triggered it by using parseCommaList parse.

Haskell member

The bug was caused by missing parentheses in the UserConstraint parser: +++ and <++ are right-associative, so a +++ b +++ c <++ d is parsed as (a +++ (b +++ (c <++ d))).

@23Skidoo 23Skidoo added a commit that closed this issue Jan 1, 2013
@23Skidoo 23Skidoo Make the UserConstraint parser non-ambiguous.
`+++` and `<++` are right-associative, so `a +++ b +++ c <++ d` is parsed as
`(a +++ (b +++ (c <++ d)))`.

Fixes #1159.
@23Skidoo 23Skidoo closed this in 03af50b Jan 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment