New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream fibs example breaks: forward reference extends over definition #9909

Closed
scabug opened this Issue Sep 1, 2016 · 3 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Sep 1, 2016

The example given for Streams fails to compile with this error:

Error:(597, 60) forward reference extends over definition of value fibs
    val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 }

https://github.com/scala/scala/blob/2.12.x/src/library/scala/collection/immutable/Stream.scala#L23-L38

import scala.math.BigInt
/*
 *  object Main extends App {
 *
 *    val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip(fibs.tail).map { n => n._1 + n._2 }
 *
 *    fibs take 5 foreach println
 *  }
 *
 *  // prints
 *  //
 *  // 0
 *  // 1
 *  // 1
 *  // 2
 *  // 3
@scabug

This comment has been minimized.

Copy link
Author

scabug commented Sep 1, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9909?orig=1
Reporter: Alejandro Wainzinger (xevix)
Assignee: Tim Spence (timspence)
Affected Versions: 2.11.8

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Sep 1, 2016

Tim Spence (timspence) said:
I can't seem to assign this to myself but I have submitted a PR for it

scala/scala#5373

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Sep 1, 2016

@som-snytt said:
They need executable examples for scaladoc and also for jira issue descriptions.

The issue is this question about the local val or more illustratively this umbrella question.

Probably the doc should use a uniform style, such as a local def and an initializer expression for a val, to avoid confusion. But these semantics are part of the list of "subtle bullet points". So the tutorial doc should just explain the difference.

@scabug scabug closed this Oct 31, 2016

@scabug scabug added this to the 2.12.1 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment