From 98c8ea19d7dab0cdc2d386cecdce98f1de815ba5 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 8 Jul 2009 13:51:56 -0400 Subject: [PATCH 1/1] compile: fatal error on unknown intern method also fix tests/base_eq_null_notnull that declared an unknown intern method. Signed-off-by: Jean Privat --- src/compiling/compiling_methods.nit | 3 ++- tests/base_eq_null_notnull.nit | 3 +-- tests/error_intern.nit | 25 +++++++++++++++++++++++++ tests/sav/error_intern.sav | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/error_intern.nit create mode 100644 tests/sav/error_intern.sav diff --git a/src/compiling/compiling_methods.nit b/src/compiling/compiling_methods.nit index abcfb47..9edf071 100644 --- a/src/compiling/compiling_methods.nit +++ b/src/compiling/compiling_methods.nit @@ -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*/" diff --git a/tests/base_eq_null_notnull.nit b/tests/base_eq_null_notnull.nit index b684a09..ef08d2c 100644 --- a/tests/base_eq_null_notnull.nit +++ b/tests/base_eq_null_notnull.nit @@ -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 index 0000000..5cffb15 --- /dev/null +++ b/tests/error_intern.nit @@ -0,0 +1,25 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2009 Jean Privat +# +# 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 index 0000000..c24d838 --- /dev/null +++ b/tests/sav/error_intern.sav @@ -0,0 +1 @@ +./error_intern.nit:20,2--8: Fatal error: unknown intern method error_intern::A::foo. -- 1.7.9.5