haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Map Comprehension break/return bug

Open AxGord opened this issue 4 months ago • 0 comments

Sometimes, during the process of creating a Map, it becomes clear that the rest of its elements do not need to be created or that it is necessary to exit the current method.

Example:

[ERROR] Test.hx:3: characters 55-59

 3 |     trace([ for (i in 0...3) if (i != 2) i => 0 else break ]);
   |                                                       ^^^^
   | haxe.ds.Map<Int, Int> has no field push

However, with Array Comprehension it works fine.

As a solution, I don't use Map Comprehension in these cases, but it would be nice if it were possible. If it's hard to do, it would be better with a clearer error message.

Judging by the error message, the same method is used as for arrays, it seems that it is necessary to make a set instead of a push for Map.

AxGord avatar Aug 06 '25 09:08 AxGord