eclipse-langium / langium

Next-gen language engineering / DSL framework
https://langium.org/
MIT License
663 stars 61 forks source link

Concatenated stream elements can't be accessed multiple times #1543

Closed joao-silveira closed 2 weeks ago

joao-silveira commented 3 weeks ago

When accessing the elements of a concatenated stream, the concatenated elements are missing when accessing the stream a second time. In any case the elements passed in the stream(...) call are always available.

Langium version: 3.0.0 Package name: Langium

Code example:

const countTest = stream([1]).concat([2])
countTest.count()
countTest.toArray() // returns [ 1 ] but expected was [1, 2]
const toStringTest = stream([1]).concat([2])
toStringTest.toString()
toStringTest.toArray() // returns [ 1 ] but expected was [1 , 2]
const findTest = stream([1]).concat([2])
findTest.some((it: number) => it === 2) //returns true
findTest.some((it: number) => it === 2) //returns false but expected was true

This problem really seems to be specific to streams concatenations because i tried other variants of the code above with stream([1], [2]) or stream([1], stream([2])) and all of those work.

msujew commented 3 weeks ago

Thanks for catching, see https://github.com/eclipse-langium/langium/pull/1545 for a fix.