Skip to content

fix[lang]: block modules in structs#4566

Merged
charles-cooper merged 5 commits intovyperlang:masterfrom
cyberthirst:fix/module-instantiation
Apr 11, 2025
Merged

fix[lang]: block modules in structs#4566
charles-cooper merged 5 commits intovyperlang:masterfrom
cyberthirst:fix/module-instantiation

Conversation

@cyberthirst
Copy link
Copy Markdown
Collaborator

@cyberthirst cyberthirst commented Apr 9, 2025

What I did

modules could have been instantiated

import lib1

struct A:
    a: lib1

h: DynArray[A, 5]

a further question is whether to refactor location validation - a module can't be instantiated in storage, yet it's possible as shown in the example above. the location check should also recurse on the subtypes. i'm for refactor as it will help prevent potential future bugs

Commit Message

prior to this commit, modules could be added as a struct member,
as below:

```vyper
import lib1

struct A:
    a: lib1

h: DynArray[A, 5]
```

this commit blocks the behavior.

_attribute_in_annotation = True
_as_array = False
_as_hashmap_key = False
_as_tuple_member = False
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i don't think this is defined in the base class or used anywhere in the PR?

Copy link
Copy Markdown
Collaborator Author

@cyberthirst cyberthirst Apr 9, 2025

Choose a reason for hiding this comment

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

sorry, bad git manipulation
0cee75f

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.66%. Comparing base (0835158) to head (cb2ffbc).
Report is 85 commits behind head on master.

Files with missing lines Patch % Lines
vyper/semantics/types/subscriptable.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4566      +/-   ##
==========================================
+ Coverage   92.58%   92.66%   +0.07%     
==========================================
  Files         123      123              
  Lines       17528    17526       -2     
  Branches     2969     2971       +2     
==========================================
+ Hits        16229    16241      +12     
+ Misses        894      883      -11     
+ Partials      405      402       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

lgtm. please fix lint

@cyberthirst
Copy link
Copy Markdown
Collaborator Author

lgtm. please fix lint

addressed cb2ffbc

@charles-cooper charles-cooper changed the title fix[lang]: fix module instantiation fix[lang]: block modules in structs Apr 11, 2025
@charles-cooper charles-cooper enabled auto-merge (squash) April 11, 2025 07:01
@charles-cooper charles-cooper merged commit 8fc1d64 into vyperlang:master Apr 11, 2025
161 of 162 checks passed
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.

2 participants