-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
122 additions
and
21 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
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
7 changes: 7 additions & 0 deletions
7
test_programs/compile_success_empty/use_callers_scope/Nargo.toml
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,7 @@ | ||
[package] | ||
name = "use_callers_scope" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.34.0" | ||
|
||
[dependencies] |
34 changes: 34 additions & 0 deletions
34
test_programs/compile_success_empty/use_callers_scope/src/main.nr
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,34 @@ | ||
#[bar::struct_attr] | ||
struct Foo {} | ||
|
||
struct Bar {} | ||
|
||
#[bar::fn_attr] | ||
fn main() {} | ||
|
||
mod bar { | ||
#[use_callers_scope] | ||
pub comptime fn struct_attr(_: StructDefinition) { | ||
let _ = quote { Bar }.as_type(); | ||
} | ||
|
||
#[use_callers_scope] | ||
pub comptime fn fn_attr(_: FunctionDefinition) { | ||
let _ = quote { Bar }.as_type(); | ||
let _ = nested(); | ||
|
||
// Ensure closures can still access Bar even | ||
// though `map` separates them from `fn_attr`. | ||
let _ = &[1, 2, 3].map( | ||
|_| { | ||
quote { Bar }.as_type() | ||
} | ||
); | ||
} | ||
|
||
// use_callers_scope should also work nested | ||
#[use_callers_scope] | ||
comptime fn nested() -> Type { | ||
quote { Bar }.as_type() | ||
} | ||
} |