Skip to content

Commit ddb6bf7

Browse files
committed
feat: use Arc for variable and array references
1 parent eb860d8 commit ddb6bf7

20 files changed

+4693
-2448
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
### Changed
1616

17-
- `FlatZinc` now has two additional (and optional) generic type parameters.
18-
These allow the user to specify the type in which the mapping from identifier to variable and from identifier to array is stored.
19-
- [**breaking**] The `Annotation` variant of `AnnotationLiteral` now directly includes a value of type `AnnotationCall<Identifier>`, to avoid the ambiguity of identifier-annotations already being able to be represented using `BaseLiteral`.
2017
- [**breaking**] The `domain` field of `Variable` has now moved to a variant argument on `Type`, accessible through the `ty` attribute.
2118
- [**breaking**] The `objective` field of the `SolveMethod` struct has now moved to a variant argument on `Method`, accessible through the `method` attribute.
2219
- [**breaking**] Change the default implementation of `variables` and `arrays` field of `FlatZinc` to be `std::collections::HashMap`.
2320
- Allow the usage of stateful interners for `Identifier` using `FlatZinc::deserialize_with_interner` and `FlatZinc::from_fzn_with_interner`.
2421
- [**breaking**] Remove the `value` field from `Variable`.
2522
Any right-hand side value is now resolved during parsing.
23+
- [**breaking**] `FlatZinc` now uses `Arc<Variable>` and `Arc<Array>` to represent variable reference in `Literal`.
24+
This allowed the removal of the `Argument` type, as inline arrays are now represented as `Array` types without names.
25+
The `variables` and `arrays` attributes of `FlatZinc` are now `Vec<Arc<_>>`.
26+
`AnnotationLiteral` now contains all its own variants, it no longer has a direct `Literal` variant.
27+
This avoids strong references in annotations that might lead to self-referencing structures.
2628

2729
## [0.4.4] - 2025-11-06
2830

corpus/fzn/documentation_example.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var 0..85000: X_INTRODUCED_0_ ::is_defined_var;
21
var 0..3: b ::output_var;
32
var 0..6: c ::output_var;
3+
var 0..85000: X_INTRODUCED_0_ ::is_defined_var;
44
array[1..2] of int: X_INTRODUCED_2_ = [250, 200];
55
array[1..2] of int: X_INTRODUCED_6_ = [75, 150];
66
array[1..2] of int: X_INTRODUCED_8_ = [100, 150];

corpus/fzn/documentation_example.fzn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var 0..85000: X_INTRODUCED_0_ ::is_defined_var;
21
var 0..3: b ::output_var;
32
var 0..6: c ::output_var;
3+
var 0..85000: X_INTRODUCED_0_ ::is_defined_var;
44
array[1..2] of int: X_INTRODUCED_2_ = [250, 200];
55
array[1..2] of int: X_INTRODUCED_6_ = [75, 150];
66
array[1..2] of int: X_INTRODUCED_8_ = [100, 150];

corpus/fzn/float.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
var float: x ::output_var;
12
var bool: X_INTRODUCED_2_ ::is_defined_var ::var_is_introduced;
23
var bool: X_INTRODUCED_3_ ::is_defined_var ::var_is_introduced;
34
var bool: X_INTRODUCED_4_ ::is_defined_var ::var_is_introduced;
45
var bool: X_INTRODUCED_6_ ::is_defined_var ::var_is_introduced;
5-
var float: x ::output_var;
66
constraint float_le(1.0, x);
77
constraint bool_clause([X_INTRODUCED_4_, X_INTRODUCED_6_], []);
88
constraint float_le_reif(1.0, x, X_INTRODUCED_2_) ::defines_var(X_INTRODUCED_2_);

corpus/fzn/set_var.expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var 0..7: X_INTRODUCED_1_ ::var_is_introduced;
21
var set of -3..3: x ::output_var;
2+
var 0..7: X_INTRODUCED_1_ ::var_is_introduced;
33
constraint set_card(x, X_INTRODUCED_1_) ::ctx_pos;
44
solve maximize X_INTRODUCED_1_;

0 commit comments

Comments
 (0)