QnnOkabayashi / curse-lang

1 stars 1 forks source link

Fix struct def and piecewise function lowering #11

Closed QnnOkabayashi closed 1 year ago

QnnOkabayashi commented 1 year ago

Fixed the bugs brought up in #9 that caused

  1. struct definitions wrapping records, and
  2. piecewise functions

to become empty after lowering.

The root of the bug was that my special Iter type that implements ExactSizedIterator implemented Iterator::size_hint incorrectly, and sometimes falsely would return 0. This meant that in the lowering code, Bump::alloc_slice_fill_iter would look at the length of the iterator and see 0, thus resulting in just &[].