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

feat: Add unquote function #5497

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions compiler/noirc_frontend/src/parser/parser/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,7 @@ pub(super) fn parenthesized_type(
}

pub(super) fn maybe_comp_time() -> impl NoirParser<bool> {
keyword(Keyword::Comptime).or_not().validate(|opt, span, emit| {
if opt.is_some() {
emit(ParserError::with_reason(
ParserErrorReason::ExperimentalFeature("Comptime values"),
span,
));
}
jfecher marked this conversation as resolved.
Show resolved Hide resolved
opt.is_some()
})
keyword(Keyword::Comptime).or_not().map(|opt| opt.is_some())
}

pub(super) fn field_type() -> impl NoirParser<UnresolvedType> {
Expand Down
7 changes: 7 additions & 0 deletions noir_stdlib/src/meta/mod.nr
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
mod type_def;

/// Calling unquote as a macro (via `unquote!(arg)`) will unquote
/// its argument. Since this is the effect `!` already does, `unquote`
/// itself does not need to do anything besides return its argument.
pub comptime fn unquote(code: Quoted) -> Quoted {
code
}
7 changes: 7 additions & 0 deletions test_programs/compile_success_empty/unquote/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "unquote"
type = "bin"
authors = [""]
compiler_version = ">=0.31.0"

[dependencies]
3 changes: 3 additions & 0 deletions test_programs/compile_success_empty/unquote/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
std::meta::unquote!(quote { assert(true); });
jfecher marked this conversation as resolved.
Show resolved Hide resolved
}
Loading