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

FIXME: Create a list of structs #698

Closed
weaversa opened this issue Apr 30, 2020 · 4 comments
Closed

FIXME: Create a list of structs #698

weaversa opened this issue Apr 30, 2020 · 4 comments
Assignees
Milestone

Comments

@weaversa
Copy link
Contributor

I was trying to create a list of numElements entries, all initialized the same (by init_function with some params), and came across a "FIXME" from saw.

rec init_list numElements init_function params = do {
  list <- if (eval_bool {{ `numElements : [32] == 0 }}) then []
          else (concat [init_function params]
               (init_list (eval_int {{ `numElements : [32] - 1 }}) init_function params));
  return list;
};
[20:13:43.132] Loading file "blah.saw"
[20:13:43.174] Type errors:
 Type Mismatch, expected: t.1 -> (t.3 -> t.15) -> t.3 -> t.18 t.19 but got: Int -> (t.3 -> t.15) -> t.3 -> [t.15]
FIXME

Am I doing this right? If so, consider this FIXME a bug report. If I'm not doing it right, how can I do this?

@brianhuffman
Copy link
Contributor

brianhuffman commented Apr 30, 2020

Grepping through the sources, the only places I can see that have the "FIXME" as a Haskell string literal are this bogus source position value:

fixPos = PosInternal "FIXME"

and this call to error in the saw-script type checker:
sequence_ $ zipWith (constrainTypeWithPattern (error "FIXME")) ts pats'

I imagine the second occurrence is the one you're hitting here. I'll need to investigate to see whether this is supposed to indicate a user error or an internal panic; we should consider this a bug in either case.

@brianhuffman
Copy link
Contributor

How embarrassing: git blame says that call to error "FIXME" is totally my fault, from 4 years ago. I'll take responsibility for fixing it.

@brianhuffman brianhuffman self-assigned this Apr 30, 2020
@weaversa
Copy link
Contributor Author

weaversa commented May 2, 2020

I got FIXME again. The error is correct here. I'm just reporting in case it helps at all.

Type Mismatch, expected: t.1 -> (t.3 -> CrucibleSetup {c : Term, s : SetupValue}) -> t.3 -> CrucibleSetup {s : [SetupValue]} but got: Int -> (t.3 -> CrucibleSetup {c : Term, s : SetupValue}) -> t.3 -> CrucibleSetup {c : Term, s : [SetupValue]}
FIXME

@atomb atomb added this to the 0.6 milestone May 15, 2020
@brianhuffman brianhuffman mentioned this issue May 17, 2020
@brianhuffman
Copy link
Contributor

In PR #716, running saw on the example from the original post now gives an appropriate type error message with appropriate location information, and does not crash:

[15:57:17.477] Loading file "/Users/huffman/Documents/saw/issue698.saw"
[15:57:17.479] Type errors:
  /Users/huffman/Documents/saw/issue698.saw:1:5-6:2: Type Mismatch, expected: t.1 -> (t.3 -> t.15) -> t.3 -> t.18 t.19 but got: Int -> (t.3 -> t.15) -> t.3 -> [t.15]
 at "init_list" (/Users/huffman/Documents/saw/issue698.saw:1:5-1:14)
Type constructors mismatch. Expected: <Block> but got ([]) at "init_list" (/Users/huffman/Documents/saw/issue698.saw:1:5-1:14)

  /Users/huffman/Documents/saw/issue698.saw:1:50-6:2: Type Mismatch, expected: t.4 t.5 but got: [t.15]
 at "init_list" (/Users/huffman/Documents/saw/issue698.saw:1:5-1:14)
Type constructors mismatch. Expected: <Block> but got ([]) at "init_list" (/Users/huffman/Documents/saw/issue698.saw:1:5-1:14)

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 a pull request may close this issue.

3 participants