@ball-lang/engine 1.7.8 → 1.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1564,7 +1564,14 @@ export function createEngineSetup(mod: EngineModule) {
1564
1564
  // bare arg0 dropped `self`, so methods saw `Undefined variable: <field>`.
1565
1565
  let fixedInput = input;
1566
1566
  if (func.inputType && func.inputType.isNotEmpty && typeof input === 'object' && input !== null && !Array.isArray(input)) {
1567
- const params = (e._paramCache[((__bts(moduleName) + '.') + __bts(func.name))]) ?? (func.metadata ? e._extractParams(func.metadata) : []);
1567
+ // Lambdas have an empty `func.name`, so the cache key `'<module>.'` is
1568
+ // shared by every lambda in the module — two lambdas would collide and
1569
+ // the second's params would overwrite the first's (#246). Only consult
1570
+ // the shared cache for named functions; extract a nameless function's
1571
+ // params directly from its own metadata.
1572
+ const params = (__bts(func.name).length > 0
1573
+ ? (e._paramCache[((__bts(moduleName) + '.') + __bts(func.name))]) ?? (func.metadata ? e._extractParams(func.metadata) : [])
1574
+ : (func.metadata ? e._extractParams(func.metadata) : []));
1568
1575
  if (params.length === 1) {
1569
1576
  const inputMap = e._asMap(input);
1570
1577
  if (inputMap && 'arg0' in inputMap && !(params[0] in inputMap) && !('self' in inputMap)) {