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

eval_list fails on the empty list #783

Closed
ChrisEPhifer opened this issue Jul 20, 2020 · 1 comment · Fixed by #787
Closed

eval_list fails on the empty list #783

ChrisEPhifer opened this issue Jul 20, 2020 · 1 comment · Fixed by #787
Labels
type: bug Issues reporting bugs or unexpected/unwanted behavior

Comments

@ChrisEPhifer
Copy link
Member

ChrisEPhifer commented Jul 20, 2020

Consider the following SAWScript (note that Bit was chosen arbitrarily; any other monomorphization will also fail):

eval_list {{ [] : [0]Bit }};

This results in an error and crash: saw: arithmetic underflow.

@ChrisEPhifer ChrisEPhifer added the type: bug Issues reporting bugs or unexpected/unwanted behavior label Jul 20, 2020
@brianhuffman
Copy link
Contributor

brianhuffman commented Jul 21, 2020

The problem is in the expression traverse (scNat sc) [0 .. fromInteger n - 1] in this line of code:

idxs <- io $ traverse (scNat sc) [0 .. fromInteger n - 1]

Function scNat takes an argument of type Natural. The expression [0 .. fromInteger n - 1] is intended to evaluate to the empty list when n = 0, but the upper bound fromInteger 0 - 1 underflows on type Natural, yielding the error.

We could fix this by replacing [0 .. fromInteger n - 1] with map fromInteger [0 .. n - 1].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issues reporting bugs or unexpected/unwanted behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants