chore: repro for very strange bug#8740
chore: repro for very strange bug#8740asterite wants to merge 1 commit intoab/no-cast-from-numeric-to-boolfrom
Conversation
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 8530f89 | Previous: cb4951d | Ratio |
|---|---|---|---|
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_rollup-lib |
267 s |
192 s |
1.39 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
|
I was able to reproduce this with a much smaller code. For this program: trait Serialize {
let Size: u32;
fn serialize(self) -> [Field; Self::Size];
}
impl<A, B> Serialize for (A, B)
where
A: Serialize,
B: Serialize,
{
let Size: u32 = <A as Serialize>::Size + <B as Serialize>::Size;
fn serialize(self: Self) -> [Field; Self::Size] {
let _ = self.0.serialize();
let _ = self.1.serialize();
[0; Self::Size]
}
}
impl<T, let N: u32> Serialize for [T; N]
where
T: Serialize,
{
let Size: u32 = <T as Serialize>::Size * N;
fn serialize(self: Self) -> [Field; Self::Size] {
[0; Self::Size]
}
}
impl Serialize for Field {
let Size: u32 = 1;
fn serialize(self) -> [Field; Self::Size] {
[self]
}
}
fn main() {
let x = (((1, [2, 3, 4]), [5, 6, 7, 8]), 9);
let _ = x.serialize();
}If we change If we put this in pub fn foo() {
let _ = 1;
let _ = 1;
}Hopefully this will make finding the issue much easier 🤞 But also this means that it's likely unrelated to comptime stuff, as it happens with non-comptime stuff too (the |
|
It's also worth noting that this happens if |
|
Oh, and it also seems to happen if we move |
|
Closed in favor of this issue: #8780 |
Description
Problem
The compiler fails to compile a program if we add/remove unused variables.
Summary
If we compile the
serialize_1as it is in this PR, it fails to compile. But if we uncomment thelet a1 = quote {};variable, it compiles.Note that if it's
let a1 = 1;then it doesn't compile. For some reason if we usequote {}it compiles.Then, if we keep uncomment variables the program will compile or not compile. It seems a bit random.
This makes me think there's a bug somewhere in the comptime code. We already observed that if some code is generated via macros instead of written by hand then it might lead to slower compilation, when it shouldn't, so maybe all of these things are related. I wonder if something is leaking from the comptime interpreter that's modifying something outside of it, some global state (or bindings, type vars, not sure).
Another way: instead of uncommenting any of those variables, add this to
lib.nrfor the standard library:then the code compiles.
Additional Context
Documentation
Check one:
PR Checklist*
cargo fmton default settings.