metamodel: fast-fail in getters
[nit.git] / src / syntax / mmbuilder.nit
index ccdd2a6..db15e8b 100644 (file)
@@ -173,8 +173,9 @@ redef class MMSrcLocalClass
                                if not gp.is_init then continue
                                super_constructors.add(gp)
                        end
-                       var gp = sc.get_property_by_name(once ("init".to_symbol))
-                       if gp != null then
+                       var initname = once ("init".to_symbol)
+                       if sc.has_global_property_by_name(initname) then
+                               var gp = sc.get_property_by_name(initname)
                                super_inits.add(self[gp])
                        end
                end
@@ -851,6 +852,10 @@ redef class PPropdef
                                        v.error(self, "Redef error: {prop.local_class}::{prop} redefines {ip.local_class}::{ip} with {isig.arity} parameter(s).")
                                        return
                                end
+                               if v.signature_builder.closure_decls.length != isig.closures.length then
+                                       v.error(self, "Redef error: {prop.local_class}::{prop} redefines {ip.local_class}::{ip} with {isig.arity} closure(s).")
+                                       return
+                               end
                                for p in v.signature_builder.params do
                                        var t = isig[p.position]
                                        p.stype = t
@@ -1183,7 +1188,7 @@ redef class AClosureDecl
                        sig = new MMSignature(new Array[MMType], null, v.local_class.get_type)
                end
                if sig.return_type != null and n_kwbreak != null then
-                       v.error(self, "Syntax Error: A break bloc cannot have a return value.")
+                       v.error(self, "Syntax Error: A break block cannot have a return value.")
                end
 
                # Add the finalizer to the closure signature