Skip to content

Commit

Permalink
Merge branch 'master' into jf/fix-mutable2
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Jul 15, 2024
2 parents 6f30260 + cfd42a9 commit 8696753
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 66 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,59 @@ jobs:
working-directory: ./examples/codegen_verifier
run: ./test.sh

external-repo-checks:
needs: [build-nargo]
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
project:
- { repo: AztecProtocol/aztec-nr, path: ./ }
- { repo: AztecProtocol/aztec-packages, path: ./noir-projects/noir-contracts }
# Disabled as aztec-packages requires a setup-step in order to generate a `Nargo.toml`
#- { repo: AztecProtocol/aztec-packages, path: ./noir-projects/noir-protocol-circuits }
- { repo: zac-williamson/noir-edwards, path: ./, ref: 0016ce82cd58b6ebb0c43c271725590bcff4e755 }
# TODO: Enable these once they're passing against master again.
# - { repo: zac-williamson/noir-bignum, path: ./, ref: 030c2acce1e6b97c44a3bbbf3429ed96f20d72d3 }
# - { repo: vlayer-xyz/monorepo, path: ./, ref: ee46af88c025863872234eb05d890e1e447907cb }
# - { repo: hashcloak/noir-bigint, path: ./, ref: 940ddba3a5201b508e7b37a2ef643551afcf5ed8 }

name: Check external repo - ${{ matrix.project.repo }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ matrix.project.repo }}
path: test-repo
ref: ${{ matrix.project.ref }}

- name: Download nargo binary
uses: actions/download-artifact@v4
with:
name: nargo
path: ./nargo

- name: Set nargo on PATH
run: |
nargo_binary="${{ github.workspace }}/nargo/nargo"
chmod +x $nargo_binary
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH
export PATH="$PATH:$(dirname $nargo_binary)"
nargo -V
- name: Remove requirements on compiler version
working-directory: ./test-repo
run: |
# Github actions seems to not expand "**" in globs by default.
shopt -s globstar
sed -i '/^compiler_version/d' ./**/Nargo.toml
- name: Run nargo check
working-directory: ./test-repo/${{ matrix.project.path }}
run: nargo check

# This is a job which depends on all test jobs and reports the overall status.
# This allows us to add/remove test jobs without having to update the required workflows.
tests-end:
Expand Down
2 changes: 2 additions & 0 deletions compiler/noirc_frontend/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ pub enum PathKind {
Crate,
Dep,
Plain,
Super,
}

#[derive(Debug, PartialEq, Eq, Clone)]
Expand Down Expand Up @@ -748,6 +749,7 @@ impl Display for PathKind {
match self {
PathKind::Crate => write!(f, "crate"),
PathKind::Dep => write!(f, "dep"),
PathKind::Super => write!(f, "super"),
PathKind::Plain => write!(f, "plain"),
}
}
Expand Down
6 changes: 1 addition & 5 deletions compiler/noirc_frontend/src/hir/def_collector/dc_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,11 +732,7 @@ impl<'a> ModCollector<'a> {

context.def_interner.add_module_attributes(
mod_id,
ModuleAttributes {
name: mod_name.0.contents.clone(),
location: mod_location,
parent: self.module_id,
},
ModuleAttributes { name: mod_name.0.contents.clone(), location: mod_location },
);
}

Expand Down
24 changes: 24 additions & 0 deletions compiler/noirc_frontend/src/hir/resolution/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub enum PathResolutionError {
Unresolved(Ident),
#[error("{0} is private and not visible from the current module")]
Private(Ident),
#[error("There is no super module")]
NoSuper(Span),
}

#[derive(Debug)]
Expand Down Expand Up @@ -73,6 +75,9 @@ impl<'a> From<&'a PathResolutionError> for CustomDiagnostic {
format!("{ident} is private"),
ident.span(),
),
PathResolutionError::NoSuper(span) => {
CustomDiagnostic::simple_error(error.to_string(), String::new(), *span)
}
}
}
}
Expand Down Expand Up @@ -187,6 +192,25 @@ fn resolve_path_to_ns(
path_references,
importing_crate,
),

crate::ast::PathKind::Super => {
if let Some(parent_module_id) =
def_maps[&crate_id].modules[import_directive.module_id.0].parent
{
resolve_name_in_module(
crate_id,
importing_crate,
import_path,
parent_module_id,
def_maps,
path_references,
)
} else {
let span_start = import_directive.path.span().start();
let span = Span::from(span_start..span_start + 5); // 5 == "super".len()
Err(PathResolutionError::NoSuper(span))
}
}
}
}

Expand Down
1 change: 0 additions & 1 deletion compiler/noirc_frontend/src/node_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const IMPL_SEARCH_RECURSION_LIMIT: u32 = 10;
pub struct ModuleAttributes {
pub name: String,
pub location: Location,
pub parent: LocalModuleId,
}

type StructAttributes = Vec<SecondaryAttribute>;
Expand Down
2 changes: 2 additions & 0 deletions compiler/noirc_frontend/src/parser/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub(super) fn path() -> impl NoirParser<Path> {
choice((
path_kind(Keyword::Crate, PathKind::Crate),
path_kind(Keyword::Dep, PathKind::Dep),
path_kind(Keyword::Super, PathKind::Super),
idents().map_with_span(make_path(PathKind::Plain)),
))
}
Expand Down Expand Up @@ -64,6 +65,7 @@ mod test {
("std", PathKind::Plain),
("hash::collections", PathKind::Plain),
("crate::std::hash", PathKind::Crate),
("super::foo", PathKind::Super),
];

for (src, expected_path_kind) in cases {
Expand Down
Loading

0 comments on commit 8696753

Please sign in to comment.