compile: fatal error on unknown intern method
authorJean Privat <jean@pryen.org>
Wed, 8 Jul 2009 17:51:56 +0000 (13:51 -0400)
committerJean Privat <jean@pryen.org>
Wed, 8 Jul 2009 17:51:56 +0000 (13:51 -0400)
also fix tests/base_eq_null_notnull that declared an unknown intern method.

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

src/compiling/compiling_methods.nit
tests/base_eq_null_notnull.nit
tests/error_intern.nit [new file with mode: 0644]
tests/sav/error_intern.sav [new file with mode: 0644]

index abcfb47..9edf071 100644 (file)
@@ -963,7 +963,8 @@ redef class AInternMethPropdef
                        s = "BOX_NativeString((char*)malloc((UNTAG_Int({p[1]}) * sizeof(char))))"
 
                else
-                       v.add_instr("fprintf(stderr, \"Intern {n}\\n\"); nit_exit(1);")
+                       stderr.write("{locate}: Fatal error: unknown intern method {method.full_name}.\n")
+                       exit(1)
                end
                if method.signature.return_type != null and s == null then
                        s = "NIT_NULL /*stub*/"
index b684a09..ef08d2c 100644 (file)
@@ -19,11 +19,10 @@ import end
 class Object
        fun ==(o: nullable Object): Bool do return self is o
        fun !=(o: nullable Object): Bool do return not (self == o)
-       fun output is intern
 end
 
 class Bool
-       redef fun output is intern
+       fun output is intern
 end
 
 class A
diff --git a/tests/error_intern.nit b/tests/error_intern.nit
new file mode 100644 (file)
index 0000000..5cffb15
--- /dev/null
@@ -0,0 +1,25 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2009 Jean Privat <jean@pryen.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
+
+class A
+       fun foo is intern
+end
+
+var a = new A
+a.foo
+
diff --git a/tests/sav/error_intern.sav b/tests/sav/error_intern.sav
new file mode 100644 (file)
index 0000000..c24d838
--- /dev/null
@@ -0,0 +1 @@
+./error_intern.nit:20,2--8: Fatal error: unknown intern method error_intern::A::foo.