diff --git a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs index 4e2489a709c..6d8118588ba 100644 --- a/compiler/noirc_evaluator/src/acir/acir_context/mod.rs +++ b/compiler/noirc_evaluator/src/acir/acir_context/mod.rs @@ -1029,6 +1029,30 @@ impl> AcirContext { let zero = self.add_constant(F::zero()); let one = self.add_constant(F::one()); + // When dividing the twos complement lhs and rhs, we subtract one from the bit size + // to accurately represent the unsigned values we are dividing. + // We then internally constrain `q < 2^{max_q_bits}` during euclidean division. + // If we do not special case for binary types of one bit, we will range constrain the resulting + // quotient to be zero bits, which will cause inadvertent failures. + // We could theoretically still use this algorithm as is by incrementing the bit size by one, + // but the special case is very simple and then we don't mix the degenerate type + // into our general signed division algorithm. + // + // We know that a signed integer of bit size one can only be -1 or 0 + // Thus, we know the only valid signed division can be 0 / -1. + // 0 / -1, valid as the quotient is 0 + // -1 / -1, invalid as the quotient is 1, which cannot be represented in an i1 + // All divisions by zero are invalid + if bit_size == 1 { + let lhs_is_zero = self.eq_var(lhs, zero)?; + // The value is represented internally as one with its sign stored separately + // As we are within signed division we can just check whether we have one here. + let rhs_is_one = self.eq_var(rhs, one)?; + let both_true = self.and_var(lhs_is_zero, rhs_is_one, AcirType::unsigned(1))?; + self.assert_neq_var(both_true, zero, predicate, None)?; + return Ok((zero, zero)); + }; + // Get the sign bit of rhs by computing rhs / max_power_of_two let (rhs_leading, _) = self.euclidean_division_var(rhs, max_power_of_two, bit_size, one)?; @@ -1080,7 +1104,32 @@ impl> AcirContext { let (_, remainder_var) = match numeric_type { NumericType::Signed { bit_size } => { - self.signed_division_var(lhs, rhs, bit_size, predicate)? + // When dividing the twos complement lhs and rhs, we subtract one from the bit size + // to accurately represent the unsigned values we are dividing. + // We then internally constrain `q < 2^{max_q_bits}` during euclidean division. + // If we do not special case for binary types of one bit, we will range constrain the resulting + // quotient to be zero bits, which will cause inadvertent failures. + // We could theoretically still use `signed_division_var` here by incrementing the bit size by one, + // but the special case is very simple and then we don't mix the degenerate type + // into our general signed division algorithm. + // + // We know that a signed integer of bit size one can only be -1 or 0 + // Thus, we know the only valid signed modulo can be 0 % -1 or -1 % -1 + // 0 / -1, valid as the remainder is 0 + // -1 / -1, valid as the remainder is 0 + // All divisions by zero are invalid + if bit_size == 1 { + // We only need to check that the rhs is not zero. + // Otherwise the only valid result is zero. + let zero = self.add_constant(F::zero()); + let rhs_is_zero = self.eq_var(rhs, zero)?; + let rhs_is_zero_and_predicate_active = self.mul_var(rhs_is_zero, predicate)?; + self.assert_eq_var(rhs_is_zero_and_predicate_active, zero, None)?; + + (zero, zero) + } else { + self.signed_division_var(lhs, rhs, bit_size, predicate)? + } } _ => self.euclidean_division_var(lhs, rhs, bit_size, predicate)?, }; diff --git a/test_programs/execution_failure/div_by_zero_i1/Nargo.toml b/test_programs/execution_failure/div_by_zero_i1/Nargo.toml new file mode 100644 index 00000000000..2dfef6761cb --- /dev/null +++ b/test_programs/execution_failure/div_by_zero_i1/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "div_by_zero_i1" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_failure/div_by_zero_i1/Prover.toml b/test_programs/execution_failure/div_by_zero_i1/Prover.toml new file mode 100644 index 00000000000..d92afd05e1b --- /dev/null +++ b/test_programs/execution_failure/div_by_zero_i1/Prover.toml @@ -0,0 +1,2 @@ +a = -1 +zero = 0 diff --git a/test_programs/execution_failure/div_by_zero_i1/src/main.nr b/test_programs/execution_failure/div_by_zero_i1/src/main.nr new file mode 100644 index 00000000000..8dd3f79db95 --- /dev/null +++ b/test_programs/execution_failure/div_by_zero_i1/src/main.nr @@ -0,0 +1,3 @@ +fn main(a: i1, zero: i1) -> pub i1 { + a / zero +} diff --git a/test_programs/execution_failure/div_by_zero_modulo_i1/Nargo.toml b/test_programs/execution_failure/div_by_zero_modulo_i1/Nargo.toml new file mode 100644 index 00000000000..c7c42dac8a4 --- /dev/null +++ b/test_programs/execution_failure/div_by_zero_modulo_i1/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "div_by_zero_modulo_i1" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_failure/div_by_zero_modulo_i1/Prover.toml b/test_programs/execution_failure/div_by_zero_modulo_i1/Prover.toml new file mode 100644 index 00000000000..d92afd05e1b --- /dev/null +++ b/test_programs/execution_failure/div_by_zero_modulo_i1/Prover.toml @@ -0,0 +1,2 @@ +a = -1 +zero = 0 diff --git a/test_programs/execution_failure/div_by_zero_modulo_i1/src/main.nr b/test_programs/execution_failure/div_by_zero_modulo_i1/src/main.nr new file mode 100644 index 00000000000..8e356761e75 --- /dev/null +++ b/test_programs/execution_failure/div_by_zero_modulo_i1/src/main.nr @@ -0,0 +1,3 @@ +fn main(a: i1, zero: i1) -> pub i1 { + a % zero +} diff --git a/test_programs/execution_failure/i1_invalid_div_by_neg_one/Nargo.toml b/test_programs/execution_failure/i1_invalid_div_by_neg_one/Nargo.toml new file mode 100644 index 00000000000..505c06e6732 --- /dev/null +++ b/test_programs/execution_failure/i1_invalid_div_by_neg_one/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "i1_invalid_div_by_neg_one" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_failure/i1_invalid_div_by_neg_one/Prover.toml b/test_programs/execution_failure/i1_invalid_div_by_neg_one/Prover.toml new file mode 100644 index 00000000000..3e5511085c7 --- /dev/null +++ b/test_programs/execution_failure/i1_invalid_div_by_neg_one/Prover.toml @@ -0,0 +1 @@ +a = -1 diff --git a/test_programs/execution_failure/i1_invalid_div_by_neg_one/src/main.nr b/test_programs/execution_failure/i1_invalid_div_by_neg_one/src/main.nr new file mode 100644 index 00000000000..b51bd940dce --- /dev/null +++ b/test_programs/execution_failure/i1_invalid_div_by_neg_one/src/main.nr @@ -0,0 +1,3 @@ +fn main(a: i1) -> pub i1 { + a / a +} \ No newline at end of file diff --git a/test_programs/execution_success/i1_div_and_mod/Nargo.toml b/test_programs/execution_success/i1_div_and_mod/Nargo.toml new file mode 100644 index 00000000000..a900f9cf189 --- /dev/null +++ b/test_programs/execution_success/i1_div_and_mod/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "i1_div_and_mod" +type = "bin" +authors = [""] + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/i1_div_and_mod/Prover.toml b/test_programs/execution_success/i1_div_and_mod/Prover.toml new file mode 100644 index 00000000000..c0882b88e5d --- /dev/null +++ b/test_programs/execution_success/i1_div_and_mod/Prover.toml @@ -0,0 +1,2 @@ +a = -1 +zero = 0 \ No newline at end of file diff --git a/test_programs/execution_success/i1_div_and_mod/src/main.nr b/test_programs/execution_success/i1_div_and_mod/src/main.nr new file mode 100644 index 00000000000..1231eadc370 --- /dev/null +++ b/test_programs/execution_success/i1_div_and_mod/src/main.nr @@ -0,0 +1,12 @@ +fn main(a: i1, zero: i1) { + assert(0 / a == 0); + assert(a % a == 0); + + // This if conditional is expected to be false + // We want to test the division appropriately does not error + // under an inactive predicate + if a == 0 { + assert(a / zero == 0); + assert(a % zero == 0); + } +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..79260a4fadc --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_-9223372036854775808.snap @@ -0,0 +1,46 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "a", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + }, + { + "name": "zero", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + } + ], + "return_type": null, + "error_types": {} + }, + "bytecode": "H4sIAAAAAAAA/92YXW6DMAzHA+GzZW3R6NsOkRAo4a1XGRq9/xFWtETyAm+x1zBLUSBB//xs7EQQsR+rn+3DXEfPxk1v7+GYbQmYd82O3U0v/ExCLSVuXTcP7SyV/BTtOOledP1001LLXvdfrVZq1p0exmkcxCg7NctHP6qHEYO8MSVwDBbAgo8RGTkiF1UM+YauLyvHYxR/WQSY3JA3oQROwEJYL/BVO4/wNMibUgKnBLoZC3+3yNg62YSnMcLkytg+dyJErV9FkVMC5wS6BQu/KAoQYCTdf5FsJSVwSaB72EGyHdi+ky1CjDHkPVICL+LYHxpHRMYq8MRd9CqG/6FRMdoioNhgKqCPxQ6Z36APlMex8DTKAGMn2ilwv5eXfiLw+xy430s+ngn8xszzV52uwtMg74US+EKgW7PwT8QaBBhJl6zIKFjhP+4Y6G8VijtXOv0VzCP+xpNWv6HRFzlb2xVcN46fME53JAarx02fsrXFzpx9tnD4Inw+6bLwjbWsvZu+AWM2nt+j8VK/jBkAAA==", + "debug_symbols": "ldRNCoMwEIbhu8zahU5M/LlKKSVqLIEQJWqhSO9eFQURN99ykvfJZsSZGlNN75f1bTdQ+ZjJdbUebeeXaSbejoZe+3UaRh1GKkUekfENlan4RdRaZ6iU8e8ZkcDyFMsllissz+5yxXuuskueY3mB5UkM9sldzyLdAafxVTAsBCxuF8zy2AErdRUSFgoWGSxyWBSo4BgWCSwYFgIW9zvPi0MU12+XJSwULDJMLEMVrHP2/Tr/D5fjjw5WV87sYzv5+nQ7fvvj5vB96GrTTMGsL213y/N/", + "file_map": { + "50": { + "source": "fn main(a: i1, zero: i1) {\n assert(0 / a == 0);\n assert(a % a == 0);\n\n // This if conditional is expected to be false\n // We want to test the division appropriately does not error\n // under an inactive predicate\n if a == 0 {\n assert(a / zero == 0);\n assert(a % zero == 0);\n }\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "directive_invert" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_0.snap new file mode 100644 index 00000000000..79260a4fadc --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_0.snap @@ -0,0 +1,46 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "a", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + }, + { + "name": "zero", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + } + ], + "return_type": null, + "error_types": {} + }, + "bytecode": "H4sIAAAAAAAA/92YXW6DMAzHA+GzZW3R6NsOkRAo4a1XGRq9/xFWtETyAm+x1zBLUSBB//xs7EQQsR+rn+3DXEfPxk1v7+GYbQmYd82O3U0v/ExCLSVuXTcP7SyV/BTtOOledP1001LLXvdfrVZq1p0exmkcxCg7NctHP6qHEYO8MSVwDBbAgo8RGTkiF1UM+YauLyvHYxR/WQSY3JA3oQROwEJYL/BVO4/wNMibUgKnBLoZC3+3yNg62YSnMcLkytg+dyJErV9FkVMC5wS6BQu/KAoQYCTdf5FsJSVwSaB72EGyHdi+ky1CjDHkPVICL+LYHxpHRMYq8MRd9CqG/6FRMdoioNhgKqCPxQ6Z36APlMex8DTKAGMn2ilwv5eXfiLw+xy430s+ngn8xszzV52uwtMg74US+EKgW7PwT8QaBBhJl6zIKFjhP+4Y6G8VijtXOv0VzCP+xpNWv6HRFzlb2xVcN46fME53JAarx02fsrXFzpx9tnD4Inw+6bLwjbWsvZu+AWM2nt+j8VK/jBkAAA==", + "debug_symbols": "ldRNCoMwEIbhu8zahU5M/LlKKSVqLIEQJWqhSO9eFQURN99ykvfJZsSZGlNN75f1bTdQ+ZjJdbUebeeXaSbejoZe+3UaRh1GKkUekfENlan4RdRaZ6iU8e8ZkcDyFMsllissz+5yxXuuskueY3mB5UkM9sldzyLdAafxVTAsBCxuF8zy2AErdRUSFgoWGSxyWBSo4BgWCSwYFgIW9zvPi0MU12+XJSwULDJMLEMVrHP2/Tr/D5fjjw5WV87sYzv5+nQ7fvvj5vB96GrTTMGsL213y/N/", + "file_map": { + "50": { + "source": "fn main(a: i1, zero: i1) {\n assert(0 / a == 0);\n assert(a % a == 0);\n\n // This if conditional is expected to be false\n // We want to test the division appropriately does not error\n // under an inactive predicate\n if a == 0 {\n assert(a / zero == 0);\n assert(a % zero == 0);\n }\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "directive_invert" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..79260a4fadc --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_false_inliner_9223372036854775807.snap @@ -0,0 +1,46 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "a", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + }, + { + "name": "zero", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + } + ], + "return_type": null, + "error_types": {} + }, + "bytecode": "H4sIAAAAAAAA/92YXW6DMAzHA+GzZW3R6NsOkRAo4a1XGRq9/xFWtETyAm+x1zBLUSBB//xs7EQQsR+rn+3DXEfPxk1v7+GYbQmYd82O3U0v/ExCLSVuXTcP7SyV/BTtOOledP1001LLXvdfrVZq1p0exmkcxCg7NctHP6qHEYO8MSVwDBbAgo8RGTkiF1UM+YauLyvHYxR/WQSY3JA3oQROwEJYL/BVO4/wNMibUgKnBLoZC3+3yNg62YSnMcLkytg+dyJErV9FkVMC5wS6BQu/KAoQYCTdf5FsJSVwSaB72EGyHdi+ky1CjDHkPVICL+LYHxpHRMYq8MRd9CqG/6FRMdoioNhgKqCPxQ6Z36APlMex8DTKAGMn2ilwv5eXfiLw+xy430s+ngn8xszzV52uwtMg74US+EKgW7PwT8QaBBhJl6zIKFjhP+4Y6G8VijtXOv0VzCP+xpNWv6HRFzlb2xVcN46fME53JAarx02fsrXFzpx9tnD4Inw+6bLwjbWsvZu+AWM2nt+j8VK/jBkAAA==", + "debug_symbols": "ldRNCoMwEIbhu8zahU5M/LlKKSVqLIEQJWqhSO9eFQURN99ykvfJZsSZGlNN75f1bTdQ+ZjJdbUebeeXaSbejoZe+3UaRh1GKkUekfENlan4RdRaZ6iU8e8ZkcDyFMsllissz+5yxXuuskueY3mB5UkM9sldzyLdAafxVTAsBCxuF8zy2AErdRUSFgoWGSxyWBSo4BgWCSwYFgIW9zvPi0MU12+XJSwULDJMLEMVrHP2/Tr/D5fjjw5WV87sYzv5+nQ7fvvj5vB96GrTTMGsL213y/N/", + "file_map": { + "50": { + "source": "fn main(a: i1, zero: i1) {\n assert(0 / a == 0);\n assert(a % a == 0);\n\n // This if conditional is expected to be false\n // We want to test the division appropriately does not error\n // under an inactive predicate\n if a == 0 {\n assert(a / zero == 0);\n assert(a % zero == 0);\n }\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "directive_invert" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap new file mode 100644 index 00000000000..6203781bc3b --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_-9223372036854775808.snap @@ -0,0 +1,51 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "a", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + }, + { + "name": "zero", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + } + ], + "return_type": null, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": "H4sIAAAAAAAA/+1YTWsUQRCtnpnNZvYjil5EPIl4EA8TE5PFU5AExJPgScTDkLgexIMnES8r4kE8qRf9t2ZIF/v6WTNRdnpmhTQs3cm8ef3qVXdtsU7OhvOfamR+TuTPoZgDPxerje0WuYqYOl0knYHJTuqHPvvl55zer56nLQac075t8s+K3b3ciK9F/Ts5cEbgv6f8WRz+Yuh5Dhchv9C+KeH4HcQcAeaIMFMJiwDy6DM8q/r+5unnkizXl/06J74Y5wc1te3/VUO/7jX2sf6gWDE/0qIW5R9F4tc4B55vAPuMyF+MdxxZz4T4ec8U9KL+a37eOP1c92s9wxvw/gRwNxpwqYHrKidDiFGMPR3p6TsnDvSi/pvg4S0Jvd6E9zEntxtwzsDp/7k2cj6ZR7+L8DsP/R5STIq7AxruAkcX5yIjft4zoxg1nqwGU3eXCoqL78VBS3FdAV6hvXTvSWRPrbs2IR9RzzSyni3Dk6mhh+/anp8r/2Z+bd2hLcA9aMA5A9dVTnKIUeT/y0lOOioPH0roNd5bzMlhA84ZOL7rWP8wn8yj9Rvr3xDWOcWk+Eeg4TFwdHEuBsTPew4oRq0lSQMG11Z9tWrTqvX1iYS+9VFfOWb+7qiLQXFP/Vzxfad4+u5ZuT6sW3+kup+Bh8/9+rye9UUDzhm4delZE9LTd04S0Iv6j8HDlxJ6XdezvmrAJQaO717snvU1aHgDHF2ci6561rcU10XPuv496zs/V/699+vzetYPDThn4NalZ+X613dOuP6p/o/g4ScJva7rWT834BIDx3c9ds/6BTR8BY4uzkXbPWtC+H/tWfXZ39ZXxX+T0LdYv8Fa9RXPkPaaY1nmO1u0r2V/dpbDaqSLpSfqD44MniP+p/97ZMSUraBzvl9uz3fKeXm/PDnZPS7ZM5Hwd+vfIEVcLvEbAAA=", + "debug_symbols": "ldnNiuJAFIbhe6m1i6pzqs5JeSvD0PgTm0CIEnVgEO994mCDpEPLuxFKvjcLn4WQuoV9u71+fnTD4XgO61+30B93m0t3HKbT7b4K27Hr++7z4/XrEB8fyf/vz6fN8DieL5vxEtbarEI77MM661Qfur4N6xLvv1chNXBf2V4i3Ce4F7hXuM9wX+De4B76CvQV6KvQV6GvQl+Fvgp9Ffoq9FXoq9BXoW+Gvhn6ZuiboW9+49vM9wXuDe4d7hd9TZ578/m+sn2JcJ/gXuBe4T7DfYF7g3uHe+hboK9BX4O+Bn0N+hr0Nehr0Negr0Ffg74OfR36OvR16OvQ16Gv/+zrMt873DdwX9m+WfQVzc9AcpwXiwJSvv5ixGxeZFwUXBguHBcNLiotasRFwoXgAptXbF6xecXmFZtXbF6xeYqRJ4knwhPlSeZJ4YnxxHnS8OSdvqd5kiJPEk+EJ8v6Tf1Kqn9LMk8KT4wnzpOGJxUnyy+wfk4ST4QnXF+4vnB94frC9YXrC9dXrq9cX7m+cn3l+sr1lesr11eur1w/c/38Rl+jfEuEJ8qTzJL7dPqzGbvNtm+ftw6H67B7uYS4/D21s/uI03jctfvr2D5uJl4uJR6/Y8q+SkWmB08P/wc=", + "file_map": { + "50": { + "source": "fn main(a: i1, zero: i1) {\n assert(0 / a == 0);\n assert(a % a == 0);\n\n // This if conditional is expected to be false\n // We want to test the division appropriately does not error\n // under an inactive predicate\n if a == 0 {\n assert(a / zero == 0);\n assert(a % zero == 0);\n }\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_0.snap b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_0.snap new file mode 100644 index 00000000000..6203781bc3b --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_0.snap @@ -0,0 +1,51 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "a", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + }, + { + "name": "zero", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + } + ], + "return_type": null, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": "H4sIAAAAAAAA/+1YTWsUQRCtnpnNZvYjil5EPIl4EA8TE5PFU5AExJPgScTDkLgexIMnES8r4kE8qRf9t2ZIF/v6WTNRdnpmhTQs3cm8ef3qVXdtsU7OhvOfamR+TuTPoZgDPxerje0WuYqYOl0knYHJTuqHPvvl55zer56nLQac075t8s+K3b3ciK9F/Ts5cEbgv6f8WRz+Yuh5Dhchv9C+KeH4HcQcAeaIMFMJiwDy6DM8q/r+5unnkizXl/06J74Y5wc1te3/VUO/7jX2sf6gWDE/0qIW5R9F4tc4B55vAPuMyF+MdxxZz4T4ec8U9KL+a37eOP1c92s9wxvw/gRwNxpwqYHrKidDiFGMPR3p6TsnDvSi/pvg4S0Jvd6E9zEntxtwzsDp/7k2cj6ZR7+L8DsP/R5STIq7AxruAkcX5yIjft4zoxg1nqwGU3eXCoqL78VBS3FdAV6hvXTvSWRPrbs2IR9RzzSyni3Dk6mhh+/anp8r/2Z+bd2hLcA9aMA5A9dVTnKIUeT/y0lOOioPH0roNd5bzMlhA84ZOL7rWP8wn8yj9Rvr3xDWOcWk+Eeg4TFwdHEuBsTPew4oRq0lSQMG11Z9tWrTqvX1iYS+9VFfOWb+7qiLQXFP/Vzxfad4+u5ZuT6sW3+kup+Bh8/9+rye9UUDzhm4delZE9LTd04S0Iv6j8HDlxJ6XdezvmrAJQaO717snvU1aHgDHF2ci6561rcU10XPuv496zs/V/699+vzetYPDThn4NalZ+X613dOuP6p/o/g4ScJva7rWT834BIDx3c9ds/6BTR8BY4uzkXbPWtC+H/tWfXZ39ZXxX+T0LdYv8Fa9RXPkPaaY1nmO1u0r2V/dpbDaqSLpSfqD44MniP+p/97ZMSUraBzvl9uz3fKeXm/PDnZPS7ZM5Hwd+vfIEVcLvEbAAA=", + "debug_symbols": "ldnNiuJAFIbhe6m1i6pzqs5JeSvD0PgTm0CIEnVgEO994mCDpEPLuxFKvjcLn4WQuoV9u71+fnTD4XgO61+30B93m0t3HKbT7b4K27Hr++7z4/XrEB8fyf/vz6fN8DieL5vxEtbarEI77MM661Qfur4N6xLvv1chNXBf2V4i3Ce4F7hXuM9wX+De4B76CvQV6KvQV6GvQl+Fvgp9Ffoq9FXoq9BXoW+Gvhn6ZuiboW9+49vM9wXuDe4d7hd9TZ578/m+sn2JcJ/gXuBe4T7DfYF7g3uHe+hboK9BX4O+Bn0N+hr0Nehr0Negr0Ffg74OfR36OvR16OvQ16Gv/+zrMt873DdwX9m+WfQVzc9AcpwXiwJSvv5ixGxeZFwUXBguHBcNLiotasRFwoXgAptXbF6xecXmFZtXbF6xeYqRJ4knwhPlSeZJ4YnxxHnS8OSdvqd5kiJPEk+EJ8v6Tf1Kqn9LMk8KT4wnzpOGJxUnyy+wfk4ST4QnXF+4vnB94frC9YXrC9dXrq9cX7m+cn3l+sr1lesr11eur1w/c/38Rl+jfEuEJ8qTzJL7dPqzGbvNtm+ftw6H67B7uYS4/D21s/uI03jctfvr2D5uJl4uJR6/Y8q+SkWmB08P/wc=", + "file_map": { + "50": { + "source": "fn main(a: i1, zero: i1) {\n assert(0 / a == 0);\n assert(a % a == 0);\n\n // This if conditional is expected to be false\n // We want to test the division appropriately does not error\n // under an inactive predicate\n if a == 0 {\n assert(a / zero == 0);\n assert(a % zero == 0);\n }\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +} diff --git a/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_9223372036854775807.snap b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_9223372036854775807.snap new file mode 100644 index 00000000000..6203781bc3b --- /dev/null +++ b/tooling/nargo_cli/tests/snapshots/execution_success/i1_div_and_mod/execute__tests__force_brillig_true_inliner_9223372036854775807.snap @@ -0,0 +1,51 @@ +--- +source: tooling/nargo_cli/tests/execute.rs +expression: artifact +--- +{ + "noir_version": "[noir_version]", + "hash": "[hash]", + "abi": { + "parameters": [ + { + "name": "a", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + }, + { + "name": "zero", + "type": { + "kind": "integer", + "sign": "signed", + "width": 1 + }, + "visibility": "private" + } + ], + "return_type": null, + "error_types": { + "17843811134343075018": { + "error_kind": "string", + "string": "Stack too deep" + } + } + }, + "bytecode": "H4sIAAAAAAAA/+1YTWsUQRCtnpnNZvYjil5EPIl4EA8TE5PFU5AExJPgScTDkLgexIMnES8r4kE8qRf9t2ZIF/v6WTNRdnpmhTQs3cm8ef3qVXdtsU7OhvOfamR+TuTPoZgDPxerje0WuYqYOl0knYHJTuqHPvvl55zer56nLQac075t8s+K3b3ciK9F/Ts5cEbgv6f8WRz+Yuh5Dhchv9C+KeH4HcQcAeaIMFMJiwDy6DM8q/r+5unnkizXl/06J74Y5wc1te3/VUO/7jX2sf6gWDE/0qIW5R9F4tc4B55vAPuMyF+MdxxZz4T4ec8U9KL+a37eOP1c92s9wxvw/gRwNxpwqYHrKidDiFGMPR3p6TsnDvSi/pvg4S0Jvd6E9zEntxtwzsDp/7k2cj6ZR7+L8DsP/R5STIq7AxruAkcX5yIjft4zoxg1nqwGU3eXCoqL78VBS3FdAV6hvXTvSWRPrbs2IR9RzzSyni3Dk6mhh+/anp8r/2Z+bd2hLcA9aMA5A9dVTnKIUeT/y0lOOioPH0roNd5bzMlhA84ZOL7rWP8wn8yj9Rvr3xDWOcWk+Eeg4TFwdHEuBsTPew4oRq0lSQMG11Z9tWrTqvX1iYS+9VFfOWb+7qiLQXFP/Vzxfad4+u5ZuT6sW3+kup+Bh8/9+rye9UUDzhm4delZE9LTd04S0Iv6j8HDlxJ6XdezvmrAJQaO717snvU1aHgDHF2ci6561rcU10XPuv496zs/V/699+vzetYPDThn4NalZ+X613dOuP6p/o/g4ScJva7rWT834BIDx3c9ds/6BTR8BY4uzkXbPWtC+H/tWfXZ39ZXxX+T0LdYv8Fa9RXPkPaaY1nmO1u0r2V/dpbDaqSLpSfqD44MniP+p/97ZMSUraBzvl9uz3fKeXm/PDnZPS7ZM5Hwd+vfIEVcLvEbAAA=", + "debug_symbols": "ldnNiuJAFIbhe6m1i6pzqs5JeSvD0PgTm0CIEnVgEO994mCDpEPLuxFKvjcLn4WQuoV9u71+fnTD4XgO61+30B93m0t3HKbT7b4K27Hr++7z4/XrEB8fyf/vz6fN8DieL5vxEtbarEI77MM661Qfur4N6xLvv1chNXBf2V4i3Ce4F7hXuM9wX+De4B76CvQV6KvQV6GvQl+Fvgp9Ffoq9FXoq9BXoW+Gvhn6ZuiboW9+49vM9wXuDe4d7hd9TZ578/m+sn2JcJ/gXuBe4T7DfYF7g3uHe+hboK9BX4O+Bn0N+hr0Nehr0Negr0Ffg74OfR36OvR16OvQ16Gv/+zrMt873DdwX9m+WfQVzc9AcpwXiwJSvv5ixGxeZFwUXBguHBcNLiotasRFwoXgAptXbF6xecXmFZtXbF6xeYqRJ4knwhPlSeZJ4YnxxHnS8OSdvqd5kiJPEk+EJ8v6Tf1Kqn9LMk8KT4wnzpOGJxUnyy+wfk4ST4QnXF+4vnB94frC9YXrC9dXrq9cX7m+cn3l+sr1lesr11eur1w/c/38Rl+jfEuEJ8qTzJL7dPqzGbvNtm+ftw6H67B7uYS4/D21s/uI03jctfvr2D5uJl4uJR6/Y8q+SkWmB08P/wc=", + "file_map": { + "50": { + "source": "fn main(a: i1, zero: i1) {\n assert(0 / a == 0);\n assert(a % a == 0);\n\n // This if conditional is expected to be false\n // We want to test the division appropriately does not error\n // under an inactive predicate\n if a == 0 {\n assert(a / zero == 0);\n assert(a % zero == 0);\n }\n}\n", + "path": "" + } + }, + "names": [ + "main" + ], + "brillig_names": [ + "main" + ] +}