Skip to content

Commit

Permalink
suppress drop ability in function types, since it's common; fix par…
Browse files Browse the repository at this point in the history
…ser location on `||`
  • Loading branch information
brmataptos committed Nov 27, 2024
1 parent 44baaf0 commit be0e6e8
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Diagnostics:
error: cannot pass `|(u64, integer)|u64 with copy+drop+store` to a function which expects argument of type `|(u64, vector<u8>)|u64`
error: cannot pass `|(u64, integer)|u64 with copy+store` to a function which expects argument of type `|(u64, vector<u8>)|u64`
┌─ tests/checking/inlining/lambda_cast_err.move:7:53
7 │ vector::fold(gas_schedule_blob, (0 as u64), |sum, addend| sum + (addend as u64))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Diagnostics:
error: cannot pass `|u64|u64 with copy+drop+store` to a function which expects argument of type `|u64|`
error: cannot pass `|u64|u64 with copy+store` to a function which expects argument of type `|u64|`
┌─ tests/checking/inlining/lambda_param_mismatch.move:12:33
12 │ vector::for_each(input, |item| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ error: cannot pass `u256` to a function which expects argument of type `bool`
32 │ wrongly_typed_callee(1, 1) // Wrongly typed function application
│ ^

error: cannot pass `|num|bool with copy+drop+store` to a function which expects argument of type `|num|num`
error: cannot pass `|num|bool with copy+store` to a function which expects argument of type `|num|num`
┌─ tests/checking/specs/expressions_err.move:37:36
37 │ wrongly_typed_fun_arg_callee(|x| false) // Wrongly typed function argument.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error: cannot use `()` with an operator which expects a value of type `u64`
56 │ i = i + action(XVector::borrow(v, i)); // expected to have wrong result type
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot return `u64` from a function with result type `|integer| with copy+drop+store`
error: cannot return `u64` from a function with result type `|integer| with copy+store`
┌─ tests/checking/typing/lambda.move:61:9
61 │ x(1) // expected to be not a function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error: cannot use `()` with an operator which expects a value of type `u64`
56 │ i = i + action(XVector::borrow(v, i)); // expected to have wrong result type
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot return `u64` from a function with result type `|integer| with copy+drop+store`
error: cannot return `u64` from a function with result type `|integer| with copy+store`
┌─ tests/checking/typing/lambda_typed.move:61:9
61 │ x(1) // expected to be not a function
Expand All @@ -30,7 +30,7 @@ error: cannot use `&u64` with an operator which expects a value of type `integer
67 │ foreach(&v, |e: &u64| sum = sum + e) // expected to cannot infer type
│ ^

error: cannot pass `|&u64|u64 with copy+drop+store` to a function which expects argument of type `|&u64|`
error: cannot pass `|&u64|u64 with copy+store` to a function which expects argument of type `|&u64|`
┌─ tests/checking/typing/lambda_typed.move:73:21
73 │ foreach(&v, |e: &u64| { sum = sum + *e; *e }) // expected to have wrong result type of lambda
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Diagnostics:
error: cannot pass `|(u64, integer)|u64 with copy+drop+store` to a function which expects argument of type `|(u64, vector<u8>)|u64`
error: cannot pass `|(u64, integer)|u64 with copy+store` to a function which expects argument of type `|(u64, vector<u8>)|u64`
┌─ tests/lambda/inline-parity/lambda_cast_err.move:26:52
26 │ vector_fold(gas_schedule_blob, (0 as u64), |sum, addend| sum + (addend as u64))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Diagnostics:
error: cannot pass `|(u64, integer)|u64 with copy+drop+store` to a function which expects argument of type `|(u64, vector<u8>)|u64`
error: cannot pass `|(u64, integer)|u64 with copy+store` to a function which expects argument of type `|(u64, vector<u8>)|u64`
┌─ tests/lambda/inline-parity/lambda_cast_err.move:26:52
26 │ vector_fold(gas_schedule_blob, (0 as u64), |sum, addend| sum + (addend as u64))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Diagnostics:
error: cannot pass `|u64|u64 with copy+drop+store` to a function which expects argument of type `|u64|`
error: cannot pass `|u64|u64 with copy+store` to a function which expects argument of type `|u64|`
┌─ tests/lambda/inline-parity/lambda_param_mismatch.move:20:32
20 │ vector_for_each(input, |item| {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Diagnostics:
error: cannot pass `|u64|u64 with copy+drop+store` to a function which expects argument of type `|u64|`
error: cannot pass `|u64|u64 with copy+store` to a function which expects argument of type `|u64|`
┌─ tests/lambda/inline-parity/lambda_param_mismatch.move:20:32
20 │ vector_for_each(input, |item| {
Expand Down
2 changes: 1 addition & 1 deletion third_party/move/move-compiler-v2/tests/lambda/lambda.exp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error: cannot use `()` with an operator which expects a value of type `u64`
56 │ i = i + action(XVector::borrow(v, i)); // expected to have wrong result type
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot return `u64` from a function with result type `|integer| with copy+drop+store`
error: cannot return `u64` from a function with result type `|integer| with copy+store`
┌─ tests/lambda/lambda.move:61:9
61 │ x(1) // expected to be not a function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ error: cannot use `()` with an operator which expects a value of type `u64`
56 │ i = i + action(XVector::borrow(v, i)); // expected to have wrong result type
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot return `u64` from a function with result type `|integer| with copy+drop+store`
error: cannot return `u64` from a function with result type `|integer| with copy+store`
┌─ tests/lambda/lambda.move:61:9
61 │ x(1) // expected to be not a function
Expand Down
2 changes: 1 addition & 1 deletion third_party/move/move-compiler-v2/tests/lambda/lambda3.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand Down
22 changes: 11 additions & 11 deletions third_party/move/move-compiler-v2/tests/lambda/lambda3.lambda.exp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -13,7 +13,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -24,7 +24,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -35,7 +35,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -46,7 +46,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -57,7 +57,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -68,7 +68,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -79,7 +79,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -90,7 +90,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -101,7 +101,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand All @@ -112,7 +112,7 @@ module 0x8675309::M {
module 0x8675309::M {
public fun lambda_not_allowed() {
{
let _x: |u64|u64 with copy+drop+store = |i: u64| Add<u64>(i, 1);
let _x: |u64|u64 with copy+store = |i: u64| Add<u64>(i, 1);
Tuple()
}
}
Expand Down
Loading

0 comments on commit be0e6e8

Please sign in to comment.