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

For -S 3.x input use latest release from 3.x versions #563

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

lwronski
Copy link
Contributor

For now, If someone pass -S 3.1 parameter to scala-cli, it throws error:

VL-D-0317:scala-cli lwronski$ scala-cli hello.sc -S 3.1
Unsupported Scala version: 3.1

My expectation is, that scala-cli use latest version from 3.1.

There are two ways to solve this problem:

  • If someone pass 3.x, we use latest scala version for 3.x (I have already done it in this PR).
  • we have to add entries to scala-versions-v1.json such as: { "3.0.2", "3.1.0", "3.2.x", ..., "3.x.x"}. Mechanism search the latest supported version for prefix "3.1", but it doesn't exists in scala-versions-v1.json, therefore the error was throw.

Is the first option good enough?

Comment on lines 293 to 297
val validMatchingVersions =
if (prefix.startsWith("3.") && prefix.length > 2) matchingVersions
else
matchingVersions
.filter(v => validMaxVersions.exists(v <= _))
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have done that slightly differently here: if some valid versions match the user input, only consider those. If no valid versions match, then look at all available Scala versions. Something like

Suggested change
val validMatchingVersions =
if (prefix.startsWith("3.") && prefix.length > 2) matchingVersions
else
matchingVersions
.filter(v => validMaxVersions.exists(v <= _))
val validMatchingVersions = {
val filtered = matchingVersions.filter(v => validMaxVersions.exists(v <= _))
if (filtered.isEmpty) matchingVersions
else filtered
}

Copy link
Contributor

Choose a reason for hiding this comment

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

That would correspond to a "best effort" to use the valid versions, while still allowing non-valid ones when these can't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, your idea is much more universal.

…r input

Co-authored-by: Alexandre Archambault <alexandre.archambault@gmail.com>
@romanowski romanowski merged commit 6612583 into VirtusLab:master Jan 24, 2022
@lwronski lwronski deleted the scala-version branch January 26, 2022 14:13
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.

None yet

3 participants