Skip to content
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

Unexpected compilation failure: "not found: value <value name>" #9171

Closed
scabug opened this issue Feb 22, 2015 · 3 comments
Closed

Unexpected compilation failure: "not found: value <value name>" #9171

scabug opened this issue Feb 22, 2015 · 3 comments

Comments

@scabug
Copy link

@scabug scabug commented Feb 22, 2015

I have encountered this problem when using scopt 3.3.0.
Here is the minimal test case that reproduces consistently.

object FailToCompileApp extends App {
  case class Options(window: Int = 30)
  val parser = new scopt.OptionParser[Options]("FailToCompileApp") {
    opt[Int]('w', "window") action { (w, options) =>
      options.copy(window = w)
    }
  }

  val options = parser.parse(args, Options()).get
  val window = options.window
}
[info] Compiling 1 Scala source to /Users/alexbool/Documents/IdeaProjects/myproject/target/scala-2.11/classes...
[error] /Users/alexbool/Documents/IdeaProjects/myproject/src/main/scala/me/alexbool/myproject/apps/FailToCompileApp.scala:7: not found: value w
[error]       options.copy(window = w)
[error]                             ^
[error] one error found
[error] (compile:compile) Compilation failed

The most exciting thing is when I remove the last line ("val window = options.window"), it compiles OK.

@scabug
Copy link
Author

@scabug scabug commented Feb 22, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9171?orig=1
Reporter: Alexander Bulaev (alexbool)
Affected Versions: 2.11.5
See #6391

@scabug
Copy link
Author

@scabug scabug commented Feb 22, 2015

@som-snytt said (edited on Feb 22, 2015 10:56:21 PM UTC):
Workaround is to annotate the window field, val window: Int = options.window.

A variant on "is it an assignment or a named arg?"

Edit: with -Ytyper-debug, error unless options also has explicit type.

|    |    |-- parser.parse(args, Options()) EXPRmode-POLYmode-QUALmode (site: value options  in Test) 
|    |    |    |-- parser.parse BYVALmode-EXPRmode-FUNmode-POLYmode (silent: value options  in Test) 
|    |    |    |    |-- parser EXPRmode-POLYmode-QUALmode (silent: value options  in Test) 
|    |    |    |    |    \-> trial.Test.parser.type (with underlying type scopt.OptionParser[trial.Options])
|    |    |    |    \-> (args: Seq[String], init: trial.Options)Option[trial.Options] <and> (args: Seq[String])(implicit ev: scopt.Zero[trial.Options])Boolean
|    |    |    caught scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving value options: while typing parser.parse(args, Options())

error] /home/apm/tmp/trial/src/main/scala/Trial.scala:15: recursive value options needs type
[error]   val options = parser.parse(args, Options()).get
[error]                             ^
@hrhino
Copy link
Member

@hrhino hrhino commented Feb 7, 2018

Fixed / obviated in 2.13.0-M3 (presumably by scala/scala#6092).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.