Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions compiler/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ mod test {
use super::test_helpers::*;
use super::*;
use crate::ast::ArrayLiteral;
use crate::macros_api::PathKind;

#[test]
fn parse_infix() {
Expand Down Expand Up @@ -1498,6 +1499,17 @@ mod test {
}
}

#[test]
fn parse_use_dep() {
let str = "use dep::{foo, bar}";
let result = parse_with(use_statement(), str);
if let Ok(TopLevelStatement::Import(UseTree { prefix, .. })) = result {
assert_eq!(prefix.kind, PathKind::Dep);
} else {
panic!("Expected a use statement, got {:?}", result);
}
}

#[test]
fn parse_type_aliases() {
let cases = vec!["type foo = u8", "type bar = String", "type baz<T> = Vec<T>"];
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/parser/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn empty_path() -> impl NoirParser<Path> {
let make_path = |kind| move |_, span| Path { segments: Vec::new(), kind, span };
let path_kind = |key, kind| keyword(key).map_with_span(make_path(kind));

choice((path_kind(Keyword::Crate, PathKind::Crate), path_kind(Keyword::Dep, PathKind::Plain)))
choice((path_kind(Keyword::Crate, PathKind::Crate), path_kind(Keyword::Dep, PathKind::Dep)))
}

pub(super) fn maybe_empty_path() -> impl NoirParser<Path> {
Expand Down
1 change: 1 addition & 0 deletions tooling/nargo_fmt/tests/expected/use_dep_tree.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use dep::{foo, bar};
1 change: 1 addition & 0 deletions tooling/nargo_fmt/tests/input/use_dep_tree.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use dep::{ foo, bar };