You are browsing as a guest. Sign up (or log in) to start making projects!

1h 38m 59s logged

Devlog: Finishing Nullable Field Narrowing

At this point, Flower could already narrow semantic unions through field access in the is / as case, and nullable field checks were supposed to be the obvious follow-through:

if maybe_box.value != null:
    label: string = maybe_box.value as string
end

Instead, I had forgotten to remove a LOT of stale code, and thus part of it was still behaving like only plain local variables could ever be narrowed.

There was also a second, smaller mismatch hiding, where null in type position was not lining up with the compiler’s actual internal null representation. ?string and string | null weren’t leading to a congruent output and at times were wobblier than they should be.

So the fix was mostly cleanup, but the meaningful kind:

  • make null in type syntax lower the same way the compiler expects
  • remove the stale var-only branches in nullable narrowing
  • let stable field paths like maybe_box.value and holder.box.value narrow properly

The funny part is that this felt bigger initially than it actually was once fixed. Nothing fundamentally new had to be invented, I just had to stop the old code from interfering with the newer code, which once I figured out how to do so it was quite quick. I spent an embarrassingly long time figuring it out…

0
16

Comments 0

No comments yet. Be the first!