niti: fix constructors with an empty return
authorJean Privat <jean@pryen.org>
Wed, 20 Dec 2017 14:20:23 +0000 (09:20 -0500)
committerJean Privat <jean@pryen.org>
Wed, 20 Dec 2017 14:41:19 +0000 (09:41 -0500)
fixes #2546

Signed-off-by: Jean Privat <jean@pryen.org>

src/interpreter/naive_interpreter.nit
tests/base_init_ret.nit [new file with mode: 0644]
tests/sav/base_init_ret.res [new file with mode: 0644]

index 5ccc8da..6c86223 100644 (file)
@@ -1702,6 +1702,8 @@ redef class AEscapeExpr
                        var i = v.expr(ne)
                        if i == null then return
                        v.escapevalue = i
+               else
+                       v.escapevalue = null
                end
                v.escapemark = self.escapemark
        end
diff --git a/tests/base_init_ret.nit b/tests/base_init_ret.nit
new file mode 100644 (file)
index 0000000..cdfb88e
--- /dev/null
@@ -0,0 +1,23 @@
+# 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 core::kernel
+
+class A
+       init
+       do
+               return
+       end
+end
+(new A).output_class_name
diff --git a/tests/sav/base_init_ret.res b/tests/sav/base_init_ret.res
new file mode 100644 (file)
index 0000000..f70f10e
--- /dev/null
@@ -0,0 +1 @@
+A