Skip to content

Commit 1977cf3

Browse files
authored
Merge pull request #588 from sjrd/scalajs-1.12.0
Announcing Scala.js 1.12.0.
2 parents 3f92cbe + 93e0235 commit 1977cf3

File tree

4 files changed

+151
-1
lines changed

4 files changed

+151
-1
lines changed

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ colors: #in hex code if not noted else
6464

6565
### VERSIONS ###
6666
versions:
67-
scalaJS: 1.11.0
67+
scalaJS: 1.12.0
6868
scalaJSBinary: 1
6969
scalaJS06x: 0.6.33
7070
scalaJS06xBinary: 0.6
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
---
2+
layout: post
3+
title: Announcing Scala.js 1.12.0
4+
category: news
5+
tags: [releases]
6+
permalink: /news/2022/09/15/announcing-scalajs-1.12.0/
7+
---
8+
9+
10+
We are excited to announce the release of Scala.js 1.12.0!
11+
12+
This release brings a number of bug fixes and enhancements.
13+
The highlights are:
14+
15+
* Support for the JavaScript operator `**`, introduced in ECMAScript 2016.
16+
* Checked exceptions for `ArrayStoreExceptions`s and `NegativeArraySizeException`s
17+
18+
The Scala standard library was upgraded to version 2.12.17 and 2.13.10.
19+
20+
Read on for more details.
21+
22+
<!--more-->
23+
24+
## Getting started
25+
26+
If you are new to Scala.js, head over to [the tutorial]({{ BASE_PATH }}/tutorial/).
27+
28+
If you need help with anything related to Scala.js, you may find our community [in `#scala-js` on Discord](https://discord.com/invite/scala) and [on Stack Overflow](https://stackoverflow.com/questions/tagged/scala.js).
29+
30+
Bug reports can be filed [on GitHub](https://github.com/scala-js/scala-js/issues).
31+
32+
## Release notes
33+
34+
If upgrading from Scala.js 0.6.x, make sure to read [the release notes of Scala.js 1.0.0]({{ BASE_PATH }}/news/2020/02/25/announcing-scalajs-1.0.0/) first, as they contain a host of important information, including breaking changes.
35+
36+
This is a **minor** release:
37+
38+
* It is backward binary compatible with all earlier versions in the 1.x series: libraries compiled with 1.0.x through 1.11.x can be used with 1.12.0 without change.
39+
* It is *not* forward binary compatible with 1.11.x: libraries compiled with 1.12.0 cannot be used with 1.11.x or earlier.
40+
* It is *not* entirely backward source compatible: it is not guaranteed that a codebase will compile *as is* when upgrading from 1.11.x (in particular in the presence of `-Xfatal-warnings`).
41+
42+
As a reminder, libraries compiled with 0.6.x cannot be used with Scala.js 1.x; they must be republished with 1.x first.
43+
44+
## Enhancements with compatibility concerns
45+
46+
### Checked exceptions for `ArrayStoreException` and `NegativeArraySizeException`
47+
48+
As documented in [the semantics of Scala.js]({{ BASE_PATH }}/doc/semantics.html#undefined-behaviors), `ArrayStoreException`s and `NegativeArraySizeException`s are Undefined Behavior in Scala.js, similarly to `ClassCastException`s and `ArrayIndexOutOfBoundsException`s.
49+
Prior to Scala.js 1.12.0, we made no effort internally to provide decent error messages, or any other kind of checks.
50+
51+
Starting with this release, erroneous conditions leading to one of these two exceptions are checked in development (fastLink) mode.
52+
They will be reported as `UndefinedBehaviorError`s in fastLink mode, and unchecked in fullLink mode.
53+
54+
In some rare situations, this may turn code that appeared to work into actively throwing an exception.
55+
56+
Like other checked behaviors, it is now possible to configure the linker so that these exceptions are *compliant*.
57+
In that case, they will be thrown as specified for the JVM, in both fastLink and fullLink.
58+
You may enable them with the following sbt settings:
59+
60+
{% highlight scala %}
61+
scalaJSLinkerConfig ~= {
62+
import org.scalajs.linker.interface.CheckedBehavior
63+
_.withSemantics(_
64+
.withArrayStores(CheckedBehavior.Compliant)
65+
.withNegativeArraySizes(CheckedBehavior.Compliant)
66+
)
67+
}
68+
{% endhighlight %}
69+
70+
This may have significant performance impact in fullLink, like other compliant behaviors.
71+
72+
### `js.Dynamic.**` now refers to the JavaScript `**` operator
73+
74+
Previously, `dynamic1 ** dynamic2` would be equivalent to the JavaScript expression `dynamic1["**"](dynamic2)`.
75+
When recompiled, `**` will now resolve the JavaScript `**` operator (see below for details).
76+
77+
If calling a method named `"**"` was intended, the above should be rewritten to `dynamic1.applyDynamic("**")(dynamic2)`.
78+
79+
## New deprecations
80+
81+
### `@JSOperator` is expected on JavaScript operator methods
82+
83+
When defining a facade type, we can model JavaScript operators using methods with specific names.
84+
For example, the facade for `js.BigInt` contains:
85+
86+
{% highlight scala %}
87+
import scala.scalajs.js
88+
import scala.scalajs.js.annotation._
89+
90+
@js.native @JSGlobal
91+
final class BigInt extends js.Object {
92+
def +(other: BigInt): BigInt = js.native
93+
...
94+
}
95+
{% endhighlight %}
96+
97+
Starting from Scala.js 1.12.0, such operator methods should be annotated with `@JSOperator`, as follows:
98+
99+
{% highlight scala %}
100+
@JSOperator def +(other: BigInt): BigInt = js.native
101+
{% endhighlight %}
102+
103+
A compiler warning will be emitted if the annotation is missing.
104+
105+
## Improvements
106+
107+
### Support for the JavaScript operator `**`
108+
109+
ECMAScript 2016 introduced the `**` operator in JavaScript.
110+
`a ** b` computes `a` raised to the power `b`, and is applicable to `number`s and `bigint`s.
111+
112+
Before Scala.js 1.12.0, it was not possible to write Scala.js code calling that operator.
113+
Scala.js 1.12.0 now supports it, through the definition of an `@JSOperator def **`, as follows:
114+
115+
{% highlight scala %}
116+
import scala.scalajs.js
117+
import scala.scalajs.js.annotation._
118+
119+
@js.native @JSGlobal
120+
final class BigInt extends js.Object {
121+
@JSOperator def **(other: BigInt): BigInt = js.native
122+
...
123+
}
124+
{% endhighlight %}
125+
126+
Without the annotation, a compiler warning will be emitted, and the definition will behave as a call to a method named `"**"` instead, for backward compatibility.
127+
If that is actually the intended semantics, the warning can be silenced with an explicit `@JSName("**")`.
128+
129+
## Bug fixes
130+
131+
The following bugs have been fixed in 1.12.0:
132+
133+
* [#4739](https://github.com/scala-js/scala-js/issues/4739) Incorrect codegen for singleton case from Scala 3 enum in Scala 2.13 codebase
134+
* [#4734](https://github.com/scala-js/scala-js/issues/4734) `j.u.ArrayDeque#pollFirst` is O(n)
135+
* [#4731](https://github.com/scala-js/scala-js/issues/4731) `j.u.Arrays.equals(Array[AnyRef])` doe not handle `null` values.
136+
* [#4753](https://github.com/scala-js/scala-js/issues/4753) The optimizer thinks that `x.getClass()` is non-nullable.
137+
* [#4755](https://github.com/scala-js/scala-js/issues/4755) The optimizer does not respect eval order of generic array get/set with nulls
138+
139+
You can find the full list [on GitHub](https://github.com/scala-js/scala-js/issues?q=is%3Aissue+milestone%3Av1.12.0+is%3Aclosed).

doc/all-api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ title: All previous versions of the Scala.js API
55

66
## All previous versions of the API
77

8+
### Scala.js 1.12.0
9+
* [1.12.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.12.0/scala/scalajs/js/index.html)
10+
* [1.12.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.12.0/)
11+
* [1.12.0 scalajs-javalib-intf]({{ site.production_url }}/api/scalajs-javalib-intf/1.12.0/)
12+
* [1.12.0 scalajs-ir]({{ site.production_url }}/api/scalajs-ir/1.12.0/org/scalajs/ir/index.html)
13+
* [1.12.0 scalajs-linker-interface]({{ site.production_url }}/api/scalajs-linker-interface/1.12.0/org/scalajs/linker/interface/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-interface-js/1.12.0/org/scalajs/linker/interface/index.html))
14+
* [1.12.0 scalajs-linker]({{ site.production_url }}/api/scalajs-linker/1.12.0/org/scalajs/linker/index.html) ([Scala.js version]({{ site.production_url }}/api/scalajs-linker-js/1.12.0/org/scalajs/linker/index.html))
15+
* [1.12.0 scalajs-test-adapter]({{ site.production_url }}/api/scalajs-sbt-test-adapter/1.12.0/org/scalajs/testing/adapter/index.html)
16+
* [1.12.0 sbt-scalajs]({{ site.production_url }}/api/sbt-scalajs/1.12.0/#org.scalajs.sbtplugin.package)
17+
818
### Scala.js 1.11.0
919
* [1.11.0 scalajs-library]({{ site.production_url }}/api/scalajs-library/1.11.0/scala/scalajs/js/index.html)
1020
* [1.11.0 scalajs-test-interface]({{ site.production_url }}/api/scalajs-test-interface/1.11.0/)

doc/internals/version-history.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Version history
55

66
## Version history of Scala.js
77

8+
- [1.12.0](/news/2022/11/23/announcing-scalajs-1.12.0/)
89
- [1.11.0](/news/2022/09/15/announcing-scalajs-1.11.0/)
910
- [1.10.1](/news/2022/06/25/announcing-scalajs-1.10.1/)
1011
- [1.10.0](/news/2022/04/04/announcing-scalajs-1.10.0/)

0 commit comments

Comments
 (0)