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

Give CompositeTypeHandler higher precedence over getUserCompositeType #2717

Merged
merged 1 commit into from
Aug 18, 2023

Conversation

m-Peter
Copy link
Contributor

@m-Peter m-Peter commented Aug 15, 2023

Closes onflow/cadence-tools#172

Description

When running the following script, in the Flow Emulator:

pub fun main(): Type? {
    return CompositeType("flow.AccountContractAdded")
}

The following error is returned:

error: [Error Code: 1054] location (flow) is not a valid location: expecting an AddressLocation, but other location types are passed
 --> b2b8424d1ef6de8f49bd006c8b7cbdba4a98c3be6e5834fb4ed1b281655293fe:2:4
  |
2 |     return CompositeType("flow.AccountContractAdded")

After the proposed change, the script runs successfully:

Result: Type<flow.AccountContractAdded>()

Note: This seemed to work in the test suite of the cadence-tools/test repository, however, it didn't work when I tried it in an actual Cadence test file.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov
Copy link

codecov bot commented Aug 15, 2023

Codecov Report

Merging #2717 (5051efd) into master (af119ed) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2717   +/-   ##
=======================================
  Coverage   79.12%   79.12%           
=======================================
  Files         333      333           
  Lines       78306    78306           
=======================================
  Hits        61962    61962           
  Misses      14047    14047           
  Partials     2297     2297           
Flag Coverage Δ
unittests 79.12% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
runtime/interpreter/interpreter.go 89.72% <100.00%> (ø)

Copy link
Member

@SupunS SupunS left a comment

Choose a reason for hiding this comment

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

LGTM!

runtime/interpreter/interpreter.go Show resolved Hide resolved
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Makes sense to ask the handler first, if available, and then check for a user-defined type otherwise 👍

@SupunS SupunS merged commit a8519ad into onflow:master Aug 18, 2023
13 of 14 checks passed
@m-Peter m-Peter deleted the composite-type-handler-precedence branch August 25, 2023 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot retrieve flow events in Test framework
3 participants