Skip to content

Commit b1b2a85

Browse files
authored
Merge pull request scala-js#4634 from sjrd/strict-floats-by-default
Fix scala-js#4612: Make strict-floats the default, and deprecate non-strict floats.
2 parents 12285ab + a1f52c7 commit b1b2a85

File tree

9 files changed

+54
-15
lines changed

9 files changed

+54
-15
lines changed

Jenkinsfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,16 @@ def Tasks = [
202202
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
203203
++$scala $testSuite$v/test \
204204
$testSuite$v/clean &&
205+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
206+
++$scala $testSuite$v/test &&
207+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
208+
'set scalaJSStage in Global := FullOptStage' \
209+
++$scala $testSuite$v/test \
210+
$testSuite$v/clean &&
211+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
212+
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
213+
++$scala $testSuite$v/test \
214+
$testSuite$v/clean &&
205215
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withAllowBigIntsForLongs(true)))' \
206216
++$scala $testSuite$v/test \
207217
$testSuite$v/clean &&
@@ -275,6 +285,22 @@ def Tasks = [
275285
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
276286
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
277287
++$scala $testSuite$v/test \
288+
$testSuite$v/clean &&
289+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
290+
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
291+
'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
292+
++$scala $testSuite$v/test &&
293+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
294+
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
295+
'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
296+
'set scalaJSStage in Global := FullOptStage' \
297+
++$scala $testSuite$v/test \
298+
$testSuite$v/clean &&
299+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
300+
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
301+
'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
302+
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
303+
++$scala $testSuite$v/test \
278304
$testSuite$v/clean
279305
''',
280306

@@ -308,6 +334,19 @@ def Tasks = [
308334
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
309335
++$scala $testSuite$v/test \
310336
$testSuite$v/clean &&
337+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
338+
'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
339+
++$scala $testSuite$v/test &&
340+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
341+
'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
342+
'set scalaJSStage in Global := FullOptStage' \
343+
++$scala $testSuite$v/test \
344+
$testSuite$v/clean &&
345+
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
346+
'set scalaJSLinkerConfig in $testSuite.v$v ~= { _.withSemantics(_.withStrictFloats(false)) }' \
347+
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
348+
++$scala $testSuite$v/test \
349+
$testSuite$v/clean &&
311350
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion).withAllowBigIntsForLongs(true)))' \
312351
++$scala $testSuite$v/test \
313352
$testSuite$v/clean &&

ir/shared/src/main/scala/org/scalajs/ir/ScalaJSVersions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import java.util.concurrent.ConcurrentHashMap
1717
import scala.util.matching.Regex
1818

1919
object ScalaJSVersions extends VersionChecks(
20-
current = "1.8.1-SNAPSHOT",
20+
current = "1.9.0-SNAPSHOT",
2121
binaryEmitted = "1.8"
2222
)
2323

linker-interface/shared/src/main/scala/org/scalajs/linker/interface/Semantics.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ final class Semantics private (
3434
def withModuleInit(moduleInit: CheckedBehavior): Semantics =
3535
copy(moduleInit = moduleInit)
3636

37+
@deprecated(
38+
"Scala.js now uses strict floats by default. " +
39+
"Non-strict float semantics are deprecated and will eventually be " +
40+
"removed.",
41+
"1.9.0")
3742
def withStrictFloats(strictFloats: Boolean): Semantics =
3843
copy(strictFloats = strictFloats)
3944

@@ -224,7 +229,7 @@ object Semantics {
224229
asInstanceOfs = Fatal,
225230
arrayIndexOutOfBounds = Fatal,
226231
moduleInit = Unchecked,
227-
strictFloats = false,
232+
strictFloats = true,
228233
productionMode = false,
229234
runtimeClassNameMapper = RuntimeClassNameMapper.keepAll())
230235
}

linker/shared/src/test/scala/org/scalajs/linker/LibrarySizeTest.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class LibrarySizeTest {
7070
)
7171

7272
testLinkedSizes(
73-
expectedFastLinkSize = 187341,
74-
expectedFullLinkSizeWithoutClosure = 174498,
75-
expectedFullLinkSizeWithClosure = 31513,
73+
expectedFastLinkSize = 187512,
74+
expectedFullLinkSizeWithoutClosure = 174703,
75+
expectedFullLinkSizeWithClosure = 31649,
7676
classDefs,
7777
moduleInitializers = MainTestModuleInitializers
7878
)
@@ -116,15 +116,15 @@ object LibrarySizeTest {
116116
val fastSize = fastOutput.content("main.js").get.length
117117
val fullSize = fullOutput.content("main.js").get.length
118118

119-
val expectedFullLinkSize =
120-
if (fullLinkConfig.closureCompiler) expectedFullLinkSizeWithClosure
121-
else expectedFullLinkSizeWithoutClosure
119+
val (expectedFullLinkSize, fullLinkTolerance) =
120+
if (fullLinkConfig.closureCompiler) (expectedFullLinkSizeWithClosure, 100)
121+
else (expectedFullLinkSizeWithoutClosure, 500)
122122

123123
def roughlyEquals(expected: Int, actual: Int, tolerance: Int): Boolean =
124124
actual >= expected - tolerance && actual <= expected + tolerance
125125

126126
if (!roughlyEquals(expectedFastLinkSize, fastSize, 500) ||
127-
!roughlyEquals(expectedFullLinkSize, fullSize, 100)) {
127+
!roughlyEquals(expectedFullLinkSize, fullSize, fullLinkTolerance)) {
128128
fail(
129129
s"\nFastLink expected $expectedFastLinkSize but got $fastSize" +
130130
s"\nFullLink expected $expectedFullLinkSize but got $fullSize")

partest-suite/src/test/resources/scala/tools/partest/scalajs/2.11.12/run/issue192.sem

Lines changed: 0 additions & 1 deletion
This file was deleted.

partest-suite/src/test/resources/scala/tools/partest/scalajs/2.12.15/run/issue192.sem

Lines changed: 0 additions & 1 deletion
This file was deleted.

partest-suite/src/test/resources/scala/tools/partest/scalajs/2.13.6/run/issue192.sem

Lines changed: 0 additions & 1 deletion
This file was deleted.

partest/src/main/scala/scala/tools/nsc/MainGenericRunner.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class MainGenericRunner {
6363
case "asInstanceOfs" => prev.withAsInstanceOfs(Compliant)
6464
case "arrayIndexOutOfBounds" => prev.withArrayIndexOutOfBounds(Compliant)
6565
case "moduleInit" => prev.withModuleInit(Compliant)
66-
case "strictFloats" => prev.withStrictFloats(true)
6766
}
6867
}
6968
}

project/Build.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ object ExposedValues extends AutoPlugin {
4444
.withAsInstanceOfs(CheckedBehavior.Compliant)
4545
.withArrayIndexOutOfBounds(CheckedBehavior.Compliant)
4646
.withModuleInit(CheckedBehavior.Compliant)
47-
.withStrictFloats(true)
4847
}
4948
}
5049

@@ -1725,7 +1724,7 @@ object Build {
17251724
scalaVersion.value match {
17261725
case Default2_11ScalaVersion =>
17271726
Some(ExpectedSizes(
1728-
fastLink = 520000 to 521000,
1727+
fastLink = 521000 to 522000,
17291728
fullLink = 108000 to 109000,
17301729
fastLinkGz = 66000 to 67000,
17311730
fullLinkGz = 28000 to 29000,

0 commit comments

Comments
 (0)