conjure-cp / conjure

Conjure: The Automated Constraint Modelling Tool
Other
96 stars 20 forks source link

Unclear error when reusing name as record member #551

Closed ChrisJefferson closed 1 year ago

ChrisJefferson commented 1 year ago

In the following spec I use blocks as a variable name and record name. The constraint is considering blocks as the record member.

This is (possibly) two bugs:

1) Don't allow name collisions if these aren't independent namespaces. 2) Maybe a slighter nicer error is someone tries to quantify over a record name (which is, I think, just nonsense)

This issue came up because I thought I'd be "clever" and store the neighbourhood with the same name as the variable it is a neighbourhood for.

language ESSENCE' 1.0

find blocks : function (total) int(1..5) --> int(1..5)
find neighbourhood : variant { None, Some : record {  blocks: function (total) int(1..5) --> int(1..5) } }

such that

and([true | b <- blocks])
ozgurakgun commented 1 year ago

good find, thanks. does your branch do any better @Maurice-Byrne ?

Maurice-Byrne commented 1 year ago

image It doesn't crash, but the error message is still a bit cryptic.

ozgurakgun commented 1 year ago

Yes, we need a check for record/variant field names. I'll add this.

ozgurakgun commented 1 year ago

Not claiming this is the best error message, especially since it doesn't include line numbers, but it's an improvement. Maurice can add the line numbers :)

ozgurakgun commented 1 year ago

This is the output: https://github.com/conjure-cp/conjure/blob/6a86d1fa23496e8ac21bb0bd20aa189d6ca36b05/tests/custom/issues/551/stderr.expected