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

Propagate pending array contracts in permissive_eval #1854

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions core/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,12 +956,17 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
slf.reset();
}
Ok(t) => match t.as_ref() {
Term::Array(ts, _) => {
Term::Array(ts, attrs) => {
for t in ts.iter() {
// After eval_closure, all the array elements are
// closurized already, so we don't need to do any tracking
// of the env.
inner(slf, acc, t.clone());
let value_with_ctr = RuntimeContract::apply_all(
yannham marked this conversation as resolved.
Show resolved Hide resolved
t.clone(),
attrs.pending_contracts.iter().cloned(),
t.pos,
);
inner(slf, acc, value_with_ctr);
}
}
Term::Record(data) => {
Expand Down
13 changes: 13 additions & 0 deletions lsp/nls/tests/inputs/diagnostics-array.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### /diagnostics-array.ncl
[
[
"a",
] | Array Number,
[
{ num = "str" }
] | Array { num | Number },
[
[ "a" ]
] | Array (Array Number),
]
### diagnostic = ["file:///diagnostics-array.ncl"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
source: lsp/nls/tests/main.rs
expression: output
---
(file:///diagnostics-array.ncl, 2:4-2:7: applied to this expression)
(file:///diagnostics-array.ncl, 3:12-3:18: contract broken by a value)
(file:///diagnostics-array.ncl, 3:12-3:18: expected array element type)
(file:///diagnostics-array.ncl, 5:12-5:17: applied to this expression)
(file:///diagnostics-array.ncl, 6:20-6:26: contract broken by the value of `num`)
(file:///diagnostics-array.ncl, 6:20-6:26: expected type)
(file:///diagnostics-array.ncl, 8:6-8:9: applied to this expression)
(file:///diagnostics-array.ncl, 9:19-9:25: contract broken by a value)
(file:///diagnostics-array.ncl, 9:19-9:25: expected array element type)
Loading