Skip to content

Commit

Permalink
Merge branch 'master' into tf/reorganize-integration-tests
Browse files Browse the repository at this point in the history
* master:
  fix: Improve error message when multiplying unit values (#2950)
  chore: Perform lazy initialization inside `noir_js` (#2951)
  • Loading branch information
TomAFrench committed Oct 3, 2023
2 parents 929393d + 57b7c55 commit 67d8272
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TEST_LOG_LEVEL } from '../environment.js';
import { Logger } from 'tslog';
import { initializeResolver } from '@noir-lang/source-resolver';
import newCompiler, { compile, init_log_level as compilerLogLevel } from '@noir-lang/noir_wasm';
import { acvm, abi, Noir } from '@noir-lang/noir_js';
import { Noir } from '@noir-lang/noir_js';
import { BarretenbergBackend } from '@noir-lang/backend_barretenberg';
import { ethers } from 'ethers';
import * as TOML from 'smol-toml';
Expand All @@ -13,12 +13,7 @@ import { separatePublicInputsFromProof } from '../shared/proof.js';
const provider = new ethers.JsonRpcProvider('http://localhost:8545');
const logger = new Logger({ name: 'test', minLevel: TEST_LOG_LEVEL });

const { default: initACVM } = acvm;
const { default: newABICoder } = abi;

await newCompiler();
await newABICoder();
await initACVM();

compilerLogLevel('INFO');

Expand Down
7 changes: 4 additions & 3 deletions compiler/noirc_frontend/src/hir/type_check/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use thiserror::Error;
use crate::hir::resolution::errors::ResolverError;
use crate::hir_def::expr::HirBinaryOp;
use crate::hir_def::types::Type;
use crate::BinaryOpKind;
use crate::FunctionReturnType;
use crate::Signedness;

Expand All @@ -23,8 +24,8 @@ pub enum Source {
StringLen,
#[error("Comparison")]
Comparison,
#[error("BinOp")]
BinOp,
#[error("{0}")]
BinOp(BinaryOpKind),
#[error("Return")]
Return(FunctionReturnType, Span),
}
Expand Down Expand Up @@ -218,7 +219,7 @@ impl From<TypeCheckError> for Diagnostic {
Source::ArrayLen => format!("Can only compare arrays of the same length. Here LHS is of length {expected}, and RHS is {actual}"),
Source::StringLen => format!("Can only compare strings of the same length. Here LHS is of length {expected}, and RHS is {actual}"),
Source::Comparison => format!("Unsupported types for comparison: {expected} and {actual}"),
Source::BinOp => format!("Unsupported types for binary operation: {expected} and {actual}"),
Source::BinOp(kind) => format!("Unsupported types for operator `{kind}`: {expected} and {actual}"),
Source::Return(ret_ty, expr_span) => {
let ret_ty_span = match ret_ty.clone() {
FunctionReturnType::Default(span) => span,
Expand Down
4 changes: 1 addition & 3 deletions compiler/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,6 @@ impl<'interner> TypeChecker<'interner> {
Err(TypeCheckError::InvalidInfixOp { kind: "Tuples", span })
}

(Unit, _) | (_, Unit) => Ok(Unit),

// The result of two Fields is always a witness
(FieldElement, FieldElement) => {
if op.is_bitwise() {
Expand All @@ -1075,7 +1073,7 @@ impl<'interner> TypeChecker<'interner> {
(lhs, rhs) => Err(TypeCheckError::TypeMismatchWithSource {
expected: lhs.clone(),
actual: rhs.clone(),
source: Source::BinOp,
source: Source::BinOp(op.kind),
span,
}),
}
Expand Down
1 change: 1 addition & 0 deletions tooling/noir_js/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class Noir {

// Initial inputs to your program
async generateFinalProof(inputs: any): Promise<Uint8Array> {
await this.init();
const serializedWitness = await generateWitness(this.circuit, inputs);
return this.backend.generateFinalProof(serializedWitness);
}
Expand Down

0 comments on commit 67d8272

Please sign in to comment.