Skip to content

[BUG] MiniZinc parser crashes on a model with float vars #1098

@SYury

Description

@SYury

Describe the bug
Consider the following MiniZinc model:

var -100.0..100.0: x;
var -100.0..100.0: y;
constraint 2 * x + 3 * y >= 10;
solve satisfy;

When I run Choco on this model in MiniZinc IDE, it crashes with the following stacktrace:

%% Choco 231102
line 1:44 mismatched input '.' expecting {',', ']'}
Exception in thread "main" java.lang.UnsupportedOperationException: Parameter#buildArray ARRAY: unexpected type for X_INTRODUCED_2_
	at org.chocosolver.parser.flatzinc.ast.FParameter.buildArray(FParameter.java:162)
	at org.chocosolver.parser.flatzinc.ast.FParameter.make_parameter(FParameter.java:49)
	at org.chocosolver.parser.flatzinc.Flatzinc4Parser.param_decl(Flatzinc4Parser.java:1168)
	at org.chocosolver.parser.flatzinc.Flatzinc4Parser.flatzinc_model(Flatzinc4Parser.java:212)
	at org.chocosolver.parser.flatzinc.Flatzinc.parse(Flatzinc.java:199)
	at org.chocosolver.parser.flatzinc.Flatzinc.buildModel(Flatzinc.java:152)
	at org.chocosolver.parser.flatzinc.ChocoFZN.main(ChocoFZN.java:27)

It looks like the line array [1..2] of float: X_INTRODUCED_2_ = [-2.0,-3.0]; in generated flatzinc representation kills the parser. When I change the variables to ints it works.
Environment (please complete the following information):

  • Choco-solver 4.10.14 (I found no related commits since the release, so the bug is probably still around)
  • MiniZinc IDE 2.8.4
  • JRE 22.0.1
  • Windows 10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions