Strange "value not found"-compiler error

88 views
Skip to first unread message

Andreas Joseph Krogh

unread,
May 24, 2017, 6:23:31 AM5/24/17
to scala...@googlegroups.com
Hi all, I have this code-snippet:
val stateParam: Option[ExtendedStatusState] = ExtendedStatusStateVar.get

var criteria = stateParam.map(state =>
   state.criteria.copy(endLocalDate = state.criteria.endLocalDate)
).getOrElse{...
 
Which throws this compile-error:
 
 
[ERROR] /home/andreak/dev/officenet_origo/frontend/application/src/main/scala/no/officenet/origo/frontend/lift/snippet/report/extendedstatus/ExtendedStatusMonthYearSnippet.scala:80: not found: value state 
[ERROR]                 state.criteria.copy(endLocalDate = state.criteria.endLocalDate)
[ERROR]                                                    ^
 
Any ideas?
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

Andreas Joseph Krogh

unread,
May 24, 2017, 6:24:54 AM5/24/17
to scala...@googlegroups.com
På onsdag 24. mai 2017 kl. 12:23:17, skrev Andreas Joseph Krogh <and...@visena.com>:
Hi all, I have this code-snippet:
val stateParam: Option[ExtendedStatusState] = ExtendedStatusStateVar.get

var criteria = stateParam.map(state =>
   state.criteria.copy(endLocalDate = state.criteria.endLocalDate)
).getOrElse{...
 
Which throws this compile-error:
 
 
[ERROR] /home/andreak/dev/officenet_origo/frontend/application/src/main/scala/no/officenet/origo/frontend/lift/snippet/report/extendedstatus/ExtendedStatusMonthYearSnippet.scala:80: not found: value state 
[ERROR]                 state.criteria.copy(endLocalDate = state.criteria.endLocalDate)
[ERROR]                                                    ^
 
Any ideas?
 
BTW; Using Scala-2.12.2

Dennis Haupt

unread,
May 24, 2017, 6:32:42 AM5/24/17
to Andreas Joseph Krogh, scala...@googlegroups.com
i've come across this once but forgot the solution ;(
 
Gesendet: Mittwoch, 24. Mai 2017 um 12:24 Uhr
Von: "Andreas Joseph Krogh" <and...@visena.com>
An: scala...@googlegroups.com
Betreff: Sv: [scala-user] Strange "value not found"-compiler error
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jasper-M

unread,
May 24, 2017, 9:54:36 AM5/24/17
to scala-user
Probably something to do with these issues, if that's any help to you...

https://github.com/scala/bug/issues/9171
https://github.com/scala/bug/issues/6391

Op woensdag 24 mei 2017 12:23:31 UTC+2 schreef andreak:

Oliver Ruebenacker

unread,
May 24, 2017, 10:39:18 AM5/24/17
to Jasper-M, scala-user

     Hello,

  Would be nice to have something self-contained.

  What happened if you replace the argument expression with ???:

val stateParam: Option[ExtendedStatusState] = ExtendedStatusStateVar.get

var criteria = stateParam
.map(state =>
   state.criteria.copy(endLocalDate = ???).getOrElse{...

     Best, Oliver

--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal, Broad Institute

Andreas Joseph Krogh

unread,
May 25, 2017, 5:07:50 AM5/25/17
to Oliver Ruebenacker, Jasper-M, scala-user
På onsdag 24. mai 2017 kl. 16:39:08, skrev Oliver Ruebenacker <cur...@gmail.com>:
 
     Hello,
 
  Would be nice to have something self-contained.
 
  What happened if you replace the argument expression with ???:
 
val stateParam: Option[ExtendedStatusState] = ExtendedStatusStateVar.get

var criteria = stateParam.map(state =>
   state.criteria.copy(endLocalDate = ???).getOrElse{...

     Best, Oliver
 
Here's a test-case:
 

 
import org.joda.time.LocalDate

case class Criteria(endLocalDate: LocalDate)

class TestFisk {

   var criteria = Some(Criteria(LocalDate.now())).map(crit =>
      crit.copy(endLocalDate = crit.endLocalDate)
   ).getOrElse(Criteria(LocalDate.now))

   def endLocalDate = criteria.endLocalDate.plusYears(1).monthOfYear().withMaximumValue()

}
 
Error:(10, 28) not found: value crit
        crit.copy(endLocalDate = crit.endLocalDate)
 
It seems it's the 
def endLocalDate
 
which is causing the trouble. I think this is a bug because the named parameter endLocalDate in copy() should be unambiguous regardless if there's a def with the same name in scope.
 
If I annotate the return-type of def endLoalDate it compiles fine:
var criteria = Some(Criteria(LocalDate.now())).map(crit =>
   crit.copy(endLocalDate = crit.endLocalDate)
).getOrElse(Criteria(LocalDate.now))

def endLocalDate: LocalDate = criteria.endLocalDate.plusYears(1).monthOfYear().withMaximumValue()
Reply all
Reply to author
Forward
0 new messages