lyng/lynglib
sergeych f145a90845 Fix method slot ID collision between instance and static methods
When createField() was called with a pre-assigned methodId, the ID was
used but methodIdMap was not updated and nextMethodId was not advanced.
This caused assignMethodId() for static methods to reuse slot IDs
already occupied by instance methods.

In complex.lyng, fromInt/imaginary got IDs 12/14 (same as plus/mul),
causing binary operator dispatch via CALL_MEMBER_SLOT to call the wrong
function (e.g. a*b would invoke imaginary instead of mul).

Fix: after computing effectiveMethodId in createField, always register
it in methodIdMap and advance nextMethodId past it so subsequent
auto-assignments start from a clean range.

Also pre-assigns method IDs for non-static fun/fn declarations during
class body pre-scan so forward references resolve correctly in class
bodies, and adds ComplexModuleTest coverage for operator slot dispatch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 19:41:18 +03:00
..