Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rules] [clausification, tautologies] Support for arguments #48

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

HanielB
Copy link
Contributor

@HanielB HanielB commented Nov 22, 2024

The semantics of the rules and, not_or, and_pos, and or_neg changed so that now they expect an argument as to the position in which the concluding element is from an n-ary application of the operators and or or.

The semantics of the rules `and`, `not_or`, `and_pos`, and `or_neg` changed so
that now they expect an argument as to the position in which the concluding
element is from an n-ary application of the operators `and` or `or`.
Ok(())
assert_eq(
&conclusion[0],
&and_contents[args[0].as_integer().unwrap().to_usize().unwrap()],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By calling .as_integer().unwrap() here, we will panic if the argument is not an integer term. It would be better to return an error, with .as_integer_err()?:

Suggested change
&and_contents[args[0].as_integer().unwrap().to_usize().unwrap()],
&and_contents[args[0].as_integer_err()?.to_usize().unwrap()],

Also, since we are simply accessing and_contents with [], this code will also panic if the index is out-of-bounds. It would be better to check that the argument value is in bounds, and return a nice error otherwise.

(The same thing applies to the other rules changed)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points, thanks! I'll fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants