Hi,

I am seeing odd behavior when I redefine a val in the REPL of a recent
release of the spark-shell.  Here is my minimal test case:
   val a = 1
   def id(a:Int) = {a}
   val a = 2
   a
   id(a)

Specifically, if I run "~/spark/bin/spark-shell --master local" and
enter each of these five lines one-by-one (not in :paste mode, because
of the redefinition), I get the output at the end of my message below.
The unusual thing is that "a" returns 2, but "id(a)" still returns 1.

I believe that the example is sensitive to the variable name use!  I
can also reproduce the problem with more complicated "dependencies" in
the variable name use, e.g. if I define id using b, but val b was
defined using a:
   val a = 1
   val b = a // this line is necessary for the problem!
   def id(b:Int) = {b}
   val a = 2
   a
   id(a)

I cannot reproduce this behavior in the Scala REPL directly for the
few versions and configurations that I've tried, but I may have not
been able to find the appropriate version.  That is, my Scala
interactions have all returned 2 for both of the last two expressions.

Does anyone have any thoughts?  Is this the desired behavior for some
reason?  Or is this a bug?  Why does it happen in either case?

Thanks!
Boris

===

Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 1.5.0
      /_/

Using Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_60)
Type in expressions to have them evaluated.
Type :help for more information.

scala> val a = 1
a: Int = 1

scala> def id(a:Int) = {a}
id: (a: Int)Int

scala> val a = 2
a: Int = 2

scala> a
res0: Int = 2

scala> id(a)
res1: Int = 1

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

Reply via email to