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

[compiler-v2] Pattern matching for struct variants (aka enum types) #13725

Merged
merged 2 commits into from
Jun 24, 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
@@ -0,0 +1 @@
processed 4 tasks
6 changes: 6 additions & 0 deletions third_party/move/evm/move-to-yul/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@

// Unimplemented
Vector => unimplemented!("vector"),
TestVariant(..)
| PackVariant(..)
| UnpackVariant(..)
| BorrowFieldVariant(..) => {
unimplemented!("variants")

Check warning on line 555 in third_party/move/evm/move-to-yul/src/functions.rs

View check run for this annotation

Codecov / codecov/patch

third_party/move/evm/move-to-yul/src/functions.rs#L555

Added line #L555 was not covered by tests
},

// Specification or other operations which can be ignored here
Release
Expand Down
951 changes: 837 additions & 114 deletions third_party/move/move-compiler-v2/src/bytecode_generator.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ impl<'a> FunctionGenerator<'a> {
self.flush_any_conflicts(ctx, dest, source);
let fun_ctx = ctx.fun_ctx;
match oper {
Operation::TestVariant(..)
| Operation::PackVariant(..)
| Operation::UnpackVariant(..)
| Operation::BorrowFieldVariant(..) => {
fun_ctx.internal_error("variants not yet implemented")
},
Operation::Function(mid, fid, inst) => {
self.gen_call(ctx, dest, mid.qualified(*fid), inst, source);
},
Expand Down Expand Up @@ -992,7 +998,10 @@ impl<'a> FunctionGenerator<'a> {
impl<'env> FunctionContext<'env> {
/// Emits an internal error for this function.
pub fn internal_error(&self, msg: impl AsRef<str>) {
self.module.internal_error(&self.loc, msg)
self.module.internal_error(
&self.loc,
format!("file format generator: {}", msg.as_ref()),
)
}

/// Gets the type of the temporary.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@

Diagnostics:
error: value of type `M::S<signer>` does not have the `copy` ability
┌─ tests/ability-check/v1-signer/read_ref_transitive.move:5:9
5 │ *&x
│ ^^^ reference content copied here

error: value of type `signer` does not have the `copy` ability
┌─ tests/ability-check/v1-signer/read_ref_transitive.move:15:9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ error: value of type `M::R` does not have the `drop` ability
┌─ tests/ability-check/v1-typing/assign_pop_resource.move:5:9
5 │ _ = R{};
│ ^^^^^^^ implicitly dropped here since it is no longer used
│ ^ implicitly dropped here since it is no longer used

error: value of type `M::R` does not have the `drop` ability
┌─ tests/ability-check/v1-typing/assign_pop_resource.move:6:9
┌─ tests/ability-check/v1-typing/assign_pop_resource.move:6:10
6 │ (_, _) = (R{}, R{});
│ ^^^^^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used
│ ^ implicitly dropped here since it is no longer used

error: value of type `M::R` does not have the `drop` ability
┌─ tests/ability-check/v1-typing/assign_pop_resource.move:6:13
6 │ (_, _) = (R{}, R{});
│ ^ implicitly dropped here since it is no longer used
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ error: local `_r` of type `M::R` does not have the `drop` ability
│ ^^^ implicitly dropped here since it is no longer used

error: value of type `M::R` does not have the `drop` ability
┌─ tests/ability-check/v1-typing/bind_pop_resource.move:9:13
┌─ tests/ability-check/v1-typing/bind_pop_resource.move:9:14
9 │ let (_, _):(R, R) = (R{}, R{});
│ ^^^^^^ implicitly dropped here since it is no longer used
│ ^ implicitly dropped here since it is no longer used

error: value of type `M::R` does not have the `drop` ability
┌─ tests/ability-check/v1-typing/bind_pop_resource.move:9:17
9 │ let (_, _):(R, R) = (R{}, R{});
│ ^ implicitly dropped here since it is no longer used
Loading
Loading