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] fix field selection after indexing for receiver call #15239

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rahxephon89
Copy link
Contributor

@rahxephon89 rahxephon89 commented Nov 8, 2024

Description

This PR fixes field selection after resource and vector indexing for receiver call of which the first argument is mutable reference. The following code can pass compilation:

module 0x42::m {
    struct S has key, drop { t: T }

    struct T has store, drop {
        w: W
    }

    struct W has store, drop {
        x: u64
    }

    fun merge(self: &mut W, s: W) {
        self.x += s.x;
    }

    fun foo(account: address, w: W) acquires S {
        S[account].t.w.merge(w)
    }

    fun boo(v: vector<S>, w: W) {
        v[0].t.w.merge(w)
    }

Close #15224

How Has This Been Tested?

Key Areas to Review

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Nov 8, 2024

⏱️ 14m total CI duration on this PR
Job Cumulative Duration Recent Runs
rust-move-tests 10m 🟩
rust-cargo-deny 2m 🟩
check-dynamic-deps 1m 🟩
general-lints 25s 🟩
semgrep/ci 22s 🟩
file_change_determinator 9s 🟩
permission-check 3s 🟩
permission-check 2s 🟩

settingsfeedbackdocs ⋅ learn more about trunk.io

@rahxephon89 rahxephon89 changed the title [Compiler-v2][WIP] fix field selection after indexing for receiver call [Compiler-v2] fix field selection after indexing for receiver call Nov 8, 2024
@rahxephon89 rahxephon89 marked this pull request as ready for review November 8, 2024 04:44
"receiver call needs to have at least one parameter"
);
let receiver_call_opt = self.get_receiver_function(&arg_types[0], name);
if let (Some(receiver_call), Exp_::ExpDotted(dotted)) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test case where receiver_call_opt would be None? When I tried this out, we get a "unknown receiver function" error, but might be good to have a test to prevent any regressions.

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 this pull request may close these issues.

[compiler-v2] Field selection after resource indexing not mutable
2 participants