johnynek / bosatsu

A python-ish pure and total functional programming language
Apache License 2.0
226 stars 11 forks source link

python code generation has a bug #1181

Closed johnynek closed 8 months ago

johnynek commented 8 months ago

see the diff here:

https://github.com/johnynek/bosatsu/pull/1176/commits/d32020f178de4e87fec06256c213aa4d6546d82f

this shouldn't change anything: the order we match cases may change efficiency, but it shouldn't change the result in cases like this.

But inspecting the generated python code it is definitely wrong. The bug seems to be with python generation and not the Matchless AST since that is used for the interpretter tests which pass in both cases.

The cmp_BinNat expression is simple enough, but clearly miscompiled when the order isn't starting with Zero.