From 1b1bc8148492af85f9d5507676ef7b677cf86bcb Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Mon, 2 May 2016 16:51:37 +0300 Subject: Emit a warning when a constant expression evaluates to an ArithmeticException (#5123) --- test/files/pos/constant-warning.check | 4 ++++ test/files/pos/constant-warning.flags | 1 + test/files/pos/constant-warning.scala | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 test/files/pos/constant-warning.check create mode 100644 test/files/pos/constant-warning.flags create mode 100644 test/files/pos/constant-warning.scala (limited to 'test/files/pos') 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) +} -- cgit v1.2.3