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

map/flatMap/filter/filterWith causes non-termination #7

Closed
tonymorris opened this issue Dec 10, 2013 · 3 comments
Closed

map/flatMap/filter/filterWith causes non-termination #7

tonymorris opened this issue Dec 10, 2013 · 3 comments

Comments

@tonymorris
Copy link
Collaborator

@tonymorris tonymorris commented Dec 10, 2013

At the sbt console, occasionally using some methods would fail to produce a result

scala> myFunctor.map(x)(f)
// fails to terminate

scala> val q = myFunctor.map(x) _
scala> q(f) // however, this terminates just fine

However, this behaviour goes way if the method is not called map.

scala> myFunctor.mapmap(x)(f) // terminates

We also saw this behaviour for a method named filter.

@S11001001 has pointed out that this is due to having -optimise turned on, which we do as seen in build.sbt. The inliner bumps up the inliner score for methods name map, foreach, flatMap, filter or withFilter.

Here is a link to the source code to isMonadicMethod which is later referenced in the file.

https://github.com/scala/scala/blob/v2.10.3/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala#L153-L158

@markhibberd
Copy link
Owner

@markhibberd markhibberd commented Dec 10, 2013

Yeh, removing -optimise does fix it. Thanks @S11001001.

@markhibberd
Copy link
Owner

@markhibberd markhibberd commented Dec 10, 2013

Fixed in b8c4e3a.

@S11001001
Copy link

@S11001001 S11001001 commented Dec 10, 2013

Now you too can share in the joy of knowing about isMonadicMethod. 😃

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

Successfully merging a pull request may close this issue.

None yet
3 participants