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

Rename and re-organize primitive operators #1937

Merged
merged 1 commit into from
Jun 7, 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# capture = 'stderr'
# command = ['eval']
let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in f { x = 0 }
let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in f { x = 0 }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# capture = 'stderr'
# command = ['eval']
let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in (f { x = 0 } : _)
let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in (f { x = 0 } : _)
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@ error: contract broken by the caller
field not allowed in tail: `x`
┌─ [INPUTS_PATH]/errors/record_forall_constraints_contract.ncl:3:19
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in f { x = 0 }
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in f { x = 0 }
│ ------- --------- evaluated to this expression
│ │
│ expected type of the argument provided by the caller

note:
┌─ [INPUTS_PATH]/errors/record_forall_constraints_contract.ncl:3:58
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in f { x = 0 }
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in f { x = 0 }
│ ^^^^^^^^^^^^^^^^^^^^^^^ While calling to r

note:
┌─ [INPUTS_PATH]/errors/record_forall_constraints_contract.ncl:3:85
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in f { x = 0 }
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in f { x = 0 }
│ ----------- (1) calling f

note:
┌─ [INPUTS_PATH]/errors/record_forall_constraints_contract.ncl:3:49
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in f { x = 0 }
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in f { x = 0 }
│ -------------------------------- (2) calling <func>


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: err
error: multiple record row declarations
┌─ [INPUTS_PATH]/errors/record_forall_constraints_typecheck.ncl:3:88
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record_insert% "x" r 1 in (f { x = 0 } : _)
3 │ let f | forall r. { ; r } -> { x: Number; r } = fun r => %record/insert% "x" r 1 in (f { x = 0 } : _)
│ ^^^^^^^^^ this expression
= Found an expression with the row `x : _a`
Expand All @@ -15,5 +15,3 @@ error: multiple record row declarations
note: while matching types
= Expected type { ; r }
= With inferred type { x : _a }


4 changes: 2 additions & 2 deletions core/src/eval/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub fn merge<C: Cache>(
// printed out when reporting the error.
let contract_for_display = mk_app!(
mk_term::op1(
UnaryOp::StaticAccess("Equal".into()),
UnaryOp::RecordAccess("Equal".into()),
Term::Var("contract".into()),
),
// We would need to substitute variables inside `t1` to make it useful to print,
Expand Down Expand Up @@ -233,7 +233,7 @@ pub fn merge<C: Cache>(
// exactly the same, but can't be shadowed.
let eq_contract = mk_app!(stdlib::internals::stdlib_contract_equal(), t1);
let result = mk_app!(
mk_term::op2(BinaryOp::ApplyContract(), eq_contract, Term::Lbl(label)),
mk_term::op2(BinaryOp::ContractApply, eq_contract, Term::Lbl(label)),
t2
)
.with_pos(pos_op);
Expand Down
12 changes: 6 additions & 6 deletions core/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
// corresponding polymorphic contract has been violated: a function tried to
// use a polymorphic sealed value.
match stack_item {
Some(OperationCont::Op2Second(BinaryOp::Unseal(), _, _, _)) => {
Some(OperationCont::Op2Second(BinaryOp::Unseal, _, _, _)) => {
self.continuate_operation(closure)?
}
Some(OperationCont::Op1(UnaryOp::Seq(), _)) => {
Some(OperationCont::Op1(UnaryOp::Seq, _)) => {
// Then, evaluate / `Seq` the inner value.
Closure { body: inner, env }
}
Expand Down Expand Up @@ -662,7 +662,7 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
});

Closure {
body: RichTerm::new(Term::Op1(UnaryOp::ChunksConcat(), arg), pos),
body: RichTerm::new(Term::Op1(UnaryOp::ChunksConcat, arg), pos),
env,
}
}
Expand Down Expand Up @@ -721,9 +721,9 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
// extensions
//
// ```
// %record_insert% exp1
// %record/insert% exp1
// (...
// (%record_insert% expn {stat1 = val1, ..., statn = valn} dyn_valn)
// (%record/insert% expn {stat1 = val1, ..., statn = valn} dyn_valn)
// ...)
// dyn_val1
//
Expand Down Expand Up @@ -751,7 +751,7 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
} = field;

let extend = mk_term::op2(
BinaryOp::DynExtend {
BinaryOp::RecordInsert {
metadata,
pending_contracts,
ext_kind,
Expand Down
Loading