summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorOlli Helenius <liff@iki.fi>2016-05-02 16:51:37 +0300
committerLukas Rytz <lukas.rytz@typesafe.com>2016-05-02 15:51:37 +0200
commit1b1bc8148492af85f9d5507676ef7b677cf86bcb (patch)
treec5fd6325bdad889d81be698737c4d841016e3592 /test/files/pos
parent86fe7de15988ea511fdc5e4f44039154cd236149 (diff)
downloadscala-1b1bc8148492af85f9d5507676ef7b677cf86bcb.tar.gz
scala-1b1bc8148492af85f9d5507676ef7b677cf86bcb.tar.bz2
scala-1b1bc8148492af85f9d5507676ef7b677cf86bcb.zip
Emit a warning when a constant expression evaluates to an ArithmeticException (#5123)
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/constant-warning.check4
-rw-r--r--test/files/pos/constant-warning.flags1
-rw-r--r--test/files/pos/constant-warning.scala3
3 files changed, 8 insertions, 0 deletions
diff --git a/test/files/pos/constant-warning.check b/test/files/pos/constant-warning.check
new file mode 100644
index 0000000000..f7df2165d1
--- /dev/null
+++ b/test/files/pos/constant-warning.check
@@ -0,0 +1,4 @@
+constant-warning.scala:2: warning: Evaluation of a constant expression results in an arithmetic error: / by zero
+ val fails = 1 + 2 / (3 - 2 - 1)
+ ^
+one warning found
diff --git a/test/files/pos/constant-warning.flags b/test/files/pos/constant-warning.flags
new file mode 100644
index 0000000000..d00cbbe77b
--- /dev/null
+++ b/test/files/pos/constant-warning.flags
@@ -0,0 +1 @@
+-Xlint:constant
diff --git a/test/files/pos/constant-warning.scala b/test/files/pos/constant-warning.scala
new file mode 100644
index 0000000000..c8ca8823e7
--- /dev/null
+++ b/test/files/pos/constant-warning.scala
@@ -0,0 +1,3 @@
+object Test {
+ val fails = 1 + 2 / (3 - 2 - 1)
+}