-
Notifications
You must be signed in to change notification settings - Fork 377
fix: general solution for accessing associated constants #8417
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
Merged
asterite
merged 16 commits into
master
from
ab/access_trait_associated_constants_via_self_general_solution
May 29, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fbda87a
fix: general solution for accessing associated constants
asterite 7c1ddea
Fixes
asterite 02cb03e
Ignore new nargo_expand test
asterite dc09a56
Wrap associated types in type variables
asterite 0502b3f
Register definition IDs for each associated constant
asterite cfcd411
Don't use type variables
asterite 1f33012
Make it work for the interpreter
asterite b0166ef
Undo unneeded change
asterite 5a2d07b
Properly handle error during comptime interpreter
asterite 8232e19
Properly handle error during monomorphization
asterite 748e262
Merge branch 'master' into ab/access_trait_associated_constants_via_s…
asterite 68a8257
Merge branch 'master' into ab/access_trait_associated_constants_via_s…
asterite bd2912b
Merge branch 'master' into ab/access_trait_associated_constants_via_s…
asterite ea7ed64
Snapshot
asterite 48ac45f
Only fetch location when needed
asterite b177feb
Merge branch 'master' into ab/access_trait_associated_constants_via_s…
asterite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test_programs/execution_success/trait_associated_constant/Nargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [package] | ||
| name = "trait_associated_constant" | ||
| type = "bin" | ||
| authors = [""] | ||
| [dependencies] |
25 changes: 25 additions & 0 deletions
25
test_programs/execution_success/trait_associated_constant/src/main.nr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| pub trait Trait { | ||
| let N: u32; | ||
|
|
||
| fn foo() -> u32; | ||
| } | ||
|
|
||
| struct Foo<let A: u32, let B: u32> {} | ||
|
|
||
| impl<let A: u32, let B: u32> Trait for Foo<A, B> { | ||
| let N: u32 = A + B; | ||
|
|
||
| fn foo() -> u32 { | ||
| Self::N | ||
| } | ||
| } | ||
|
|
||
| fn main() { | ||
| let x = Foo::<10, 20>::foo(); | ||
| assert_eq(x, 30); | ||
|
|
||
| comptime { | ||
| let x = Foo::<10, 20>::foo(); | ||
| assert_eq(x, 30); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...associated_constant/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.