Skip to content

Commit

Permalink
tests: add a new unreachable statement relates test
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Privat <[email protected]>
  • Loading branch information
privat committed Jun 27, 2024
1 parent e35e48f commit 43e7884
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/base_control_flow3.nit
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import kernel

var a
a = null
a = 1

a.output
return
# Below this line the code is unreachable

var b
b = null
b = 1
a.output
b.output
a = b
b = a

if a == b then
a = b
b = a
else
a = null
b = null
end
a.output
b.output
var c = a.as(not null)
var d = b.as(Int)
var e
e.output

#alt1#(b+1).output # Error
b = 1
#alt1#(b+1).output # Still error
2 changes: 2 additions & 0 deletions tests/sav/base_control_flow3.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
base_control_flow3.nit:25,1--5: Warning: unreachable statement.
1
3 changes: 3 additions & 0 deletions tests/sav/base_control_flow3_alt1.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alt/base_control_flow3_alt1.nit:25,1--5: Warning: unreachable statement.
alt/base_control_flow3_alt1.nit:47,3: Error: method `+` does not exists in `nullable Object`.
alt/base_control_flow3_alt1.nit:49,3: Error: method `+` does not exists in `nullable Object`.

0 comments on commit 43e7884

Please sign in to comment.