Skip to content

Commit c43374d

Browse files
authored
fix: externalised constants (#760)
There was a bug related to externalised constants when producing a report for a constraint failure. It was just a missing case for `LabelledConstant`.
1 parent 5113aec commit c43374d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

pkg/cmd/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func init() {
110110
debugCmd.Flags().Bool("mir", false, "Print constraints at MIR level")
111111
debugCmd.Flags().Bool("stats", false, "Print summary information")
112112
debugCmd.Flags().Bool("spillage", false, "Print spillage information")
113-
debugCmd.Flags().StringArrayP("set", "s", []string{}, "set value of externalised constant.")
113+
debugCmd.Flags().StringArrayP("set", "S", []string{}, "set value of externalised constant.")
114114
}
115115

116116
func printSchemas(hirSchema *hir.Schema, hir bool, mir bool, air bool, optConfig mir.OptimisationConfig) {

pkg/hir/context.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ func requiredColumnsOfTerm(e Term) *set.SortedSet[uint] {
8585
return set.NewSortedSet[uint]()
8686
case *ColumnAccess:
8787
return requiredColumnsOfColumnAccess(e)
88+
case *LabelledConstant:
89+
return set.NewSortedSet[uint]()
8890
case *Exp:
8991
return requiredColumnsOfTerm(e.Arg)
9092
case *IfZero:
@@ -138,6 +140,8 @@ func requiredCellsOfTerm(e Term, row int, tr trace.Trace) *set.AnySortedSet[trac
138140
return set.NewAnySortedSet[trace.CellRef]()
139141
case *ColumnAccess:
140142
return requiredCellsOfColumnAccess(e, row)
143+
case *LabelledConstant:
144+
return set.NewAnySortedSet[trace.CellRef]()
141145
case *Exp:
142146
return requiredCellsOfTerm(e.Arg, row, tr)
143147
case *IfZero:

pkg/hir/substitute.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ import (
2323
func substituteConstraint(mapping map[string]fr.Element, constraint sc.Constraint) {
2424
switch e := constraint.(type) {
2525
case LookupConstraint:
26-
// Subistute through source expressions
26+
// Substitute through source expressions
2727
for _, source := range e.Sources {
2828
substituteExpression(mapping, source.Expr)
2929
}
30-
// Subistute through target expressions
31-
for _, source := range e.Targets {
32-
substituteExpression(mapping, source.Expr)
30+
// Substitute through target expressions
31+
for _, target := range e.Targets {
32+
substituteExpression(mapping, target.Expr)
3333
}
3434
case RangeConstraint:
3535
substituteExpression(mapping, e.Expr.Expr)
3636
case SortedConstraint:
3737
if e.Selector.HasValue() {
3838
substituteExpression(mapping, e.Selector.Unwrap().Expr)
3939
}
40-
// Subistute through source expressions
40+
// Substitute through source expressions
4141
for _, source := range e.Sources {
4242
substituteExpression(mapping, source.Expr)
4343
}

0 commit comments

Comments
 (0)