Skip to content

Commit 4c56430

Browse files
authored
Merge pull request #498 from sjrd/arithmetic-exception-no-more-ub
4 fixes in the Semantics page.
2 parents 9b0cff0 + 1c4862f commit 4c56430

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

doc/semantics.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Currently known exhaustive list of exceptions are:
103103
* `NullPointerException`
104104
* `ArrayIndexOutOfBoundsException` and `StringIndexOutOfBoundsException`
105105
* `ClassCastException`
106-
* `ArithmeticException` (such as integer division by 0)
106+
* `ArrayStoreException`
107107
* `StackOverflowError` and other `VirtualMachineError`s
108108

109109
Because Scala.js does not receive VM support to detect such erroneous
@@ -112,18 +112,20 @@ conditions, checking them is typically too expensive.
112112
Therefore, all of these are considered
113113
[undefined behavior](http://en.wikipedia.org/wiki/Undefined_behavior).
114114

115+
**Scala.js 0.6.x only:**
116+
In Scala.js 0.6.x, `ArithmeticException`s, such as integer division by 0, are also considered undefined behavior.
117+
This is not the case in Scala.js 1.x anymore, where they are reliably thrown.
118+
115119
Some of these, however, can be configured to be compliant with the JVM
116120
specification using sbt settings.
117-
Currently, only `ClassCastException`s (thrown by invalid `asInstanceOf` calls)
121+
Currently, only `ClassCastException`s (thrown by invalid `asInstanceOf` calls) and `ArrayIndexOutOfBoundsException`s (thrown by array indexing)
118122
are configurable, but the list will probably expand in future versions.
119123

120124
Every configurable undefined behavior has 3 possible modes:
121125

122126
* `Compliant`: behaves as specified on a JVM
123127
* `Unchecked`: completely unchecked and undefined
124-
* `Fatal`: checked, but throws
125-
[`UndefinedBehaviorError`s]({{ site.production_url }}/api/scalajs-library/{{ site.versions.scalaJS }}/#scala.scalajs.runtime.UndefinedBehaviorError)
126-
instead of the specified exception.
128+
* `Fatal`: checked, but throws `UndefinedBehaviorError`s instead of the specified exception
127129

128130
By default, undefined behaviors are in `Fatal` mode for `fastOptJS` and in
129131
`Unchecked` mode for `fullOptJS`.

0 commit comments

Comments
 (0)