Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stream.addString is too eager #8680

@scabug

Description

@scabug

If a stream is defined as follows:

val s: Stream [Int] = 1 #:: s

then it can be printed as long as its tail has not yet been defined.
If however the tail is accessed (e.g. by invoking s(1)) then printing eagerly runs in a loop until the memory is exhausted:

scala> s
res0: Stream[Int] = Stream(1, ?)

scala> s(1)
res1: Int = 1

scala> s
<hangs>

@retronym located the bug in method Stream.addString.

See also the discussion on the scala-language list.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions