Skip to content

Determine supported IR versions automatically #3874

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

Merged
merged 2 commits into from
Nov 21, 2019

Conversation

gzm0
Copy link
Contributor

@gzm0 gzm0 commented Nov 20, 2019

No description provided.

@gzm0 gzm0 force-pushed the parse-versions branch 2 times, most recently from 787a386 to f6d655f Compare November 20, 2019 10:15
@gzm0 gzm0 marked this pull request as ready for review November 20, 2019 10:16
@gzm0 gzm0 requested a review from sjrd November 20, 2019 10:16
Set(binaryEmitted)
current = "1.0.0-SNAPSHOT",
/** Version of binary IR emitted by this version of Scala.js. */
binaryEmitted = "1.0-SNAPSHOT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These four lines should have 4 spaces of indentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the Scaladoc comments should be on the vals in VersionChecks. Actual arguments don't care about Scaladoc comments.


private def parseFull(v: String): (Int, Int, Int, Option[String]) = {
val fullRE = """^([0-9]+)\.([0-9]+)\.([0-9]+)(-.*)?$""".r
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider declaring that as a field of VersionChecks, similarly to binaryRE.


private def parseBinary(v: String): (Int, Int, Option[String]) = {
val m = mustMatch(binaryRE, v)
(m.group(1).toInt, m.group(2).toInt, Option(m.group(3)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(m.group(1).toInt, m.group(2).toInt, Option(m.group(3)))
(m.group(1).toInt, m.group(2).toInt, Option(m.group(3)).map(_.substring(1)))

? So that the - does not belong to the result string.

private def parseFull(v: String): (Int, Int, Int, Option[String]) = {
val fullRE = """^([0-9]+)\.([0-9]+)\.([0-9]+)(-.*)?$""".r
val m = mustMatch(fullRE, v)
(m.group(1).toInt, m.group(2).toInt, m.group(3).toInt, Option(m.group(4)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(m.group(1).toInt, m.group(2).toInt, m.group(3).toInt, Option(m.group(4)))
(m.group(1).toInt, m.group(2).toInt, m.group(3).toInt, Option(m.group(4)).map(_.substring(1)))

(see above)


require(currentMinor >= binaryMinor, "minor(current) < minor(binaryEmitted)")

require(currentPreRelease.isEmpty ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start the actual argument on the next line, since it spans multiple lines:

    require(
        currentPreRelease.isEmpty ||
        ...

binaryPreRelease == currentPreRelease,
"current is older than binaryEmitted through pre-release")

require(binaryPreRelease.isEmpty ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. In addition, add parens or braces around the && subexpression? I find it hard to read when we rely on the precedence of && over ||, especially in long expressions like this.

@sjrd
Copy link
Member

sjrd commented Nov 20, 2019

[error] .../sbt-plugin-test/project/project/../../../ir/src/main/scala/org/scalajs/ir/ScalaJSVersions.scala:58:19: not found: type IRVersionNotSupportedException
[error]         throw new IRVersionNotSupportedException(version, binaryEmitted,
[error]                   ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

It looks like we need to add IRVersionNotSupportedException.scala to https://github.com/scala-js/scala-js/blob/master/sbt-plugin-test/project/project/build.sbt

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

Successfully merging this pull request may close these issues.

2 participants