-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typechecker: Allow field references in methods
Allow creating local references to struct fields in methods. It turned out the way we were checking scope lifetimes was a bit backwards. We use this method every to guard against the inverse (the child scope outliving the parent) but the method wasn't implemented that way. To be honest I still don't understand a 100% why some tests were passing in the old implementation. We I also had to invert the exit condition to account for the fact that comptime scope parent chains are disjunct from runtime scope parent chains, but at least we now know that the json parser sample is testing for that case 😉. Fixing this also surfaced that the `stores_arguments` attribute test wasn't actually testing the feature but was passing due to the bug. I had to adjust it to actually test the failure case for it to continue to pass. Progress on #1379.
- Loading branch information
1 parent
6124409
commit ad5222f
Showing
3 changed files
with
31 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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,18 @@ | ||
/// Expect: | ||
/// - output: "42\n" | ||
|
||
struct Struct { | ||
i: i64, | ||
|
||
fn method(this) -> i64 { | ||
let i_ptr = &.i | ||
|
||
return *i_ptr | ||
} | ||
} | ||
|
||
fn main() { | ||
let s = Struct(i: 42) | ||
|
||
println("{}", s.method()) | ||
} |