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!: separating out array and slice types in the AST #4504

Merged
merged 36 commits into from
Mar 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6951dfb
wip separating out array and slice types in the AST
michaeljklein Mar 6, 2024
2f93bed
Update ordering of Type::Array construction in type_check/expr.rs
jfecher Mar 7, 2024
654732a
wip debugging and updating tests: fix parser and parser tests for amp…
michaeljklein Mar 8, 2024
23d3a72
wip debugging: test slice index, got slice index working, slice-speci…
michaeljklein Mar 8, 2024
c683028
got tests passing, update stdlib methods to take slices, fix missing …
michaeljklein Mar 11, 2024
a571593
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 11, 2024
6473805
update poseidon/mimic hash slice literals, add eq/ord/default instanc…
michaeljklein Mar 11, 2024
4f66228
added missing element_type_at_index case for slices, fixed all but on…
michaeljklein Mar 11, 2024
cd2807d
update slice literal in pedersen_hash wasm example
michaeljklein Mar 11, 2024
7a50955
remove redundant match on array vs slice
michaeljklein Mar 11, 2024
592b94d
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 11, 2024
4adc691
remove unused variable, flip result type order
michaeljklein Mar 11, 2024
cad7214
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 13, 2024
9cee3e0
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 15, 2024
88f53b5
Update noir_stdlib/src/merkle.nr
michaeljklein Mar 15, 2024
9552626
Update test_programs/compile_success_empty/intrinsic_die/src/main.nr
michaeljklein Mar 15, 2024
5992308
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 15, 2024
4214691
remove unused slice tests from frontend, fix Eq and Cmp for slices as…
michaeljklein Mar 15, 2024
370b8ae
remove unused PartialEq
michaeljklein Mar 15, 2024
0b59ecc
add back [hash]_array methods, use those methods in tests/stdlib
michaeljklein Mar 15, 2024
41e6ae0
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 15, 2024
e2fdfa9
fix slice literal from merge
michaeljklein Mar 15, 2024
2a5cb84
update docs for slices, fix/remove missing docs links, fix duplicated…
michaeljklein Mar 18, 2024
b1302d8
update docs pass: add missing as_slice's, fix old types for stdlib fu…
michaeljklein Mar 18, 2024
3378b8e
nargo fmt
michaeljklein Mar 18, 2024
f56a4db
Update compiler/noirc_frontend/src/ast/mod.rs
michaeljklein Mar 19, 2024
be2d631
Update compiler/noirc_frontend/src/hir_def/types.rs
michaeljklein Mar 19, 2024
57375cd
Update docs/docs/noir/standard_library/recursion.md
michaeljklein Mar 19, 2024
ce11dcc
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 19, 2024
4b62efd
Merge branch 'master' into michaeljklein/separate-slice-ast
jfecher Mar 19, 2024
1f9257b
fix duplicated error match from merging master, add docs differentiat…
michaeljklein Mar 19, 2024
bc28b78
nargo fmt
michaeljklein Mar 19, 2024
93a1e02
fix array/slice for hash in wasm test
michaeljklein Mar 19, 2024
d23dda6
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 19, 2024
e2b2ba9
include len in slice's hash, revert broken link fixes (reference fold…
michaeljklein Mar 19, 2024
7197b9c
Merge branch 'master' into michaeljklein/separate-slice-ast
michaeljklein Mar 19, 2024
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
Prev Previous commit
Next Next commit
added missing element_type_at_index case for slices, fixed all but on…
…e debugger error (timeout in brillig_cow_regression)
michaeljklein committed Mar 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 4f66228ce97360767da77d30f5b19c1dae732511
3 changes: 2 additions & 1 deletion compiler/noirc_frontend/src/monomorphization/debug.rs
Original file line number Diff line number Diff line change
@@ -192,11 +192,12 @@ impl<'interner> Monomorphizer<'interner> {
fn element_type_at_index(ptype: &PrintableType, i: usize) -> &PrintableType {
match ptype {
PrintableType::Array { length: _length, typ } => typ.as_ref(),
PrintableType::Slice { typ } => typ.as_ref(),
PrintableType::Tuple { types } => &types[i],
PrintableType::Struct { name: _name, fields } => &fields[i].1,
PrintableType::String { length: _length } => &PrintableType::UnsignedInteger { width: 8 },
_ => {
panic!["expected type with sub-fields, found terminal type"]
panic!("expected type with sub-fields, found terminal type: {:?}", ptype)
}
}
}
4 changes: 3 additions & 1 deletion tooling/debugger/tests/debug.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,9 @@ mod tests {
let nargo_bin =
cargo_bin("nargo").into_os_string().into_string().expect("Cannot parse nargo path");

let mut dbg_session = spawn_bash(Some(15000)).expect("Could not start bash session");
let timeout_seconds = 120;
let mut dbg_session =
spawn_bash(Some(timeout_seconds * 1000)).expect("Could not start bash session");

// Set backend to `/dev/null` to force an error if nargo tries to speak to a backend.
dbg_session

Unchanged files with check annotations Beta

/// br loop_entry(v0)
/// loop_entry(i: Field):
/// v2 = lt i v1
/// brif v2, then: loop_body, else: loop_end

Check warning on line 467 in compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs

GitHub Actions / Code

Unknown word (brif)
/// loop_body():
/// v3 = ... codegen body ...
/// v4 = add 1, i
/// For example, the expression `if cond { a } else { b }` is codegen'd as:
///
/// v0 = ... codegen cond ...
/// brif v0, then: then_block, else: else_block

Check warning on line 521 in compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs

GitHub Actions / Code

Unknown word (brif)
/// then_block():
/// v1 = ... codegen a ...
/// br end_if(v1)
/// As another example, the expression `if cond { a }` is codegen'd as:
///
/// v0 = ... codegen cond ...
/// brif v0, then: then_block, else: end_block

Check warning on line 534 in compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs

GitHub Actions / Code

Unknown word (brif)
/// then_block:
/// v1 = ... codegen a ...
/// br end_if()
}
ast::LValue::Dereference(_lv) => {
// TODO: this is a dummy statement for now, but we should
// somehow track the derefence and update the pointed to

Check warning on line 285 in compiler/noirc_frontend/src/debug/mod.rs

GitHub Actions / Code

Unknown word (derefence)
// variable
ast::Statement {
kind: ast::StatementKind::Expression(uint_expr(0, *span)),
ast::Pattern::Tuple(patterns, _) => {
stack.extend(patterns.iter().map(|pattern| (pattern, false)));
}
ast::Pattern::Struct(_, pids, _) => {

Check warning on line 645 in compiler/noirc_frontend/src/debug/mod.rs

GitHub Actions / Code

Unknown word (pids)
stack.extend(pids.iter().map(|(_, pattern)| (pattern, is_mut)));

Check warning on line 646 in compiler/noirc_frontend/src/debug/mod.rs

GitHub Actions / Code

Unknown word (pids)
vars.extend(pids.iter().map(|(id, _)| (id.clone(), false)));

Check warning on line 647 in compiler/noirc_frontend/src/debug/mod.rs

GitHub Actions / Code

Unknown word (pids)
}
}
}
fn pattern_to_string(pattern: &ast::Pattern) -> String {
match pattern {
ast::Pattern::Identifier(id) => id.0.contents.clone(),
ast::Pattern::Mutable(mpat, _, _) => format!("mut {}", pattern_to_string(mpat.as_ref())),

Check warning on line 657 in compiler/noirc_frontend/src/debug/mod.rs

GitHub Actions / Code

Unknown word (mpat)

Check warning on line 657 in compiler/noirc_frontend/src/debug/mod.rs

GitHub Actions / Code

Unknown word (mpat)
ast::Pattern::Tuple(elements, _) => format!(
"({})",
elements.iter().map(pattern_to_string).collect::<Vec<String>>().join(", ")
Type::Tuple(fields)
}
Type::Forall(typevars, typ) => {
// Trying to substitute_helper a variable de, substitute_bound_typevarsfined within a nested Forall

Check warning on line 1514 in compiler/noirc_frontend/src/hir_def/types.rs

GitHub Actions / Code

Unknown word (typevarsfined)
// is usually impossible and indicative of an error in the type checker somewhere.
for var in typevars {
assert!(!type_bindings.contains_key(&var.id()));