diff options
author | Olli Helenius <liff@iki.fi> | 2016-05-02 16:51:37 +0300 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2016-05-02 15:51:37 +0200 |
commit | 1b1bc8148492af85f9d5507676ef7b677cf86bcb (patch) | |
tree | c5fd6325bdad889d81be698737c4d841016e3592 /test/files | |
parent | 86fe7de15988ea511fdc5e4f44039154cd236149 (diff) | |
download | scala-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')
-rw-r--r-- | test/files/pos/constant-warning.check | 4 | ||||
-rw-r--r-- | test/files/pos/constant-warning.flags | 1 | ||||
-rw-r--r-- | test/files/pos/constant-warning.scala | 3 |
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) +} |