Skip to content

Commit

Permalink
Support checking when domain=-1
Browse files Browse the repository at this point in the history
Previously, there was no proper checking for failing constraints when
the domain of the constraint was `-1`.  This is an unexpected bug within
the tool.
  • Loading branch information
DavePearce committed Nov 11, 2024
1 parent 84571c3 commit f099bf2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ fn fail(
.collect(),
)
}

let mut trace = String::new();
for ii in 0..m_columns[0].len() {
for (j, col) in m_columns.iter().enumerate() {
Expand All @@ -218,7 +217,6 @@ fn fail(
trace.push('\n');
}
trace.push('\n');

bail!(
trace
+ &expr.debug(
Expand Down Expand Up @@ -299,7 +297,16 @@ fn check_constraint(
match domain {
Some(is) => {
for i in is.iter() {
check_constraint_at(cs, expr, i, true, true, &mut cache, settings)?;
let err = check_constraint_at(cs, expr, i, true, true, &mut cache, settings)
.map_err(|e| CheckingError::FailingConstraint(name.clone(), e.to_string()));

if err.is_err() {
if settings.continue_on_error {
eprintln!("{:?}", err);
} else {
bail!(err.err().unwrap());
}
}
}
}
None => {
Expand Down
7 changes: 4 additions & 3 deletions src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,11 @@ impl ValueBacking {
if i < 0 {
if wrap {
let new_i = v.len() as isize + i;
if new_i < 0 || new_i >= v.len() as isize {
panic!("abnormal wrapping value {}", new_i)
if new_i < 0 {
Some(v.get(0).unwrap())
} else {
v.get(new_i as usize)
}
v.get((v.len() as isize + i) as usize)
} else if i < -spilling {
Some(v.get(0).unwrap())
} else {
Expand Down

0 comments on commit f099bf2

Please sign in to comment.