tek / splain

better implicit errors for scala
MIT License
370 stars 29 forks source link

Usage example for old scala versions does not work #36

Closed mmatloka closed 4 years ago

mmatloka commented 4 years ago

Hi, I have in the code the code from https://github.com/tek/splain#usage:

libraryDependencies += {
  val v = if (scalaVersion.value <= "2.12.4") "0.4.1" else "0.5.5"
  ("io.tryp" %% "splain" % v cross CrossVersion.patch).withConfigurations(Some("plugin->default(compile)"))
}

However it does not work for Scala 2.12.10 and 2.12.11. The code sample compares strings, so "1" is < "4" so it tries to use "0.4.1".

The problem appears explicitly on 2.12.11, because splain 0.4.1 was still released for 2.12.10.

tek commented 4 years ago

I noticed that last week but forgot to change it :slightly_smiling_face: thanks!

tek commented 4 years ago

updated the instructions and bumped the version. please give it a try!

mmatloka commented 4 years ago

thanks :) probably we need to wait a few minutes, 0.5.6 is not shown yet in the repos.

mmatloka commented 4 years ago

I would propose to add also a line for 2.11 :)

mikolak-net commented 4 years ago

Might I suggest a condition like scalaVersion.value.replaceFirst(raw"\.(\d)$$",".0$1") <= "2.12.04"? Ugly regex magic, I know, but it should work for affected versions (i.e. 2.10.x and up).

mmatloka commented 4 years ago

btw scalaVersion.value.split(".") takes regexp as parameter, it should be e.g. scalaVersion.value.split("\\."), otherwise it produces empty list

joprice commented 4 years ago

There's also a char overload to avoid the escaping scalaVersion.value.split('.') https://www.scala-lang.org/api/2.12.3/scala/collection/immutable/StringOps.html#split(separator:Char):Array[String]

tek commented 4 years ago

Might I suggest a condition like scalaVersion.value.replaceFirst(raw"\.(\d)$$",".0$1") <= "2.12.04"? Ugly regex magic, I know, but it should work for affected versions (i.e. 2.10.x and up).

right, I forgot about the ancient times

tek commented 4 years ago

now we're safe until 2.12.100 :slightly_smiling_face:

tek commented 4 years ago

@mmatloka don't forget to close if you're satisfied!

mmatloka commented 4 years ago

thanks! :)