From: Alexandre Terrasa Date: Sat, 1 Feb 2014 04:47:20 +0000 (-0500) Subject: typing: standardize error messages for AForExpr loops X-Git-Tag: v0.6.4~14^2~4 X-Git-Url: http://nitlanguage.org typing: standardize error messages for AForExpr loops Signed-off-by: Alexandre Terrasa --- diff --git a/src/typing.nit b/src/typing.nit index 62e1bc0..f47f830 100644 --- a/src/typing.nit +++ b/src/typing.nit @@ -843,7 +843,7 @@ redef class AForExpr var unsafe_type = v.anchor_to(mtype) if v.try_get_mproperty_by_name2(self, unsafe_type, "iterator") == null then if v.try_get_mproperty_by_name2(self, unsafe_type, "iterate") == null then - v.error(self, "Type Error: Expected method 'iterator' in type {mtype}") + v.error(self, "Type Error: 'for' expects a type providing 'iterator' method, got '{mtype}'.") else v.modelbuilder.error(self, "NOT YET IMPLEMENTED: Do 'for' on {mtype}") end @@ -852,7 +852,7 @@ redef class AForExpr var itdef = v.get_method(self, mtype, "iterator", true) if itdef == null then - v.error(self, "Type Error: Expected method 'iterator' in type {mtype}") + v.error(self, "Type Error: 'for' expects a type providing 'iterator' method, got '{mtype}'.") return end self.method_iterator = itdef.mproperty @@ -860,7 +860,7 @@ redef class AForExpr # check that iterator return something var ittype = itdef.msignature.return_mtype if ittype == null then - v.error(self, "Type Error: Expected method 'iterator' to return an Iterator or MapIterator type") + v.error(self, "Type Error: 'for' expects method 'iterator' to return an 'Iterator' or 'MapIterator' type'.") return end @@ -875,7 +875,7 @@ redef class AForExpr var coltype = ittype.supertype_to(v.mmodule, v.anchor, colit_cla) var variables = self.variables if variables.length != 1 then - v.error(self, "Type Error: Expected one variable") + v.error(self, "Type Error: 'for' expects only one variable when using 'Iterator'.") else variables.first.declared_type = coltype.arguments.first end @@ -887,7 +887,7 @@ redef class AForExpr var coltype = ittype.supertype_to(v.mmodule, v.anchor, mapit_cla) var variables = self.variables if variables.length != 2 then - v.error(self, "Type Error: Expected two variables") + v.error(self, "Type Error: 'for' expects two variables when using 'MapIterator'.") else variables[0].declared_type = coltype.arguments[0] variables[1].declared_type = coltype.arguments[1] @@ -896,7 +896,7 @@ redef class AForExpr end if not is_col and not is_map then - v.error(self, "Type Error: Expected method 'iterator' to return an Iterator of MapIterator type") + v.error(self, "Type Error: 'for' expects method 'iterator' to return an 'Iterator' or 'MapIterator' type'.") return end @@ -909,21 +909,21 @@ redef class AForExpr # get methods is_ok, next, item var ikdef = v.get_method(self, ittype, "is_ok", false) if ikdef == null then - v.error(self, "Type Error: Expected method 'is_ok' in Iterator type {ittype}") + v.error(self, "Type Error: 'for' expects a method 'is_ok' in 'Iterator' type {ittype}.") return end self.method_is_ok = ikdef.mproperty var itemdef = v.get_method(self, ittype, "item", false) if itemdef == null then - v.error(self, "Type Error: Expected method 'item' in Iterator type {ittype}") + v.error(self, "Type Error: 'for' expects a method 'item' in 'Iterator' type {ittype}.") return end self.method_item = itemdef.mproperty var nextdef = v.get_method(self, ittype, "next", false) if nextdef == null then - v.error(self, "Type Error: Expected method 'next' in Iterator type {ittype}") + v.error(self, "Type Error: 'for' expects a method 'next' in 'Iterator' type {ittype}.") return end self.method_next = nextdef.mproperty @@ -931,7 +931,7 @@ redef class AForExpr if is_map then var keydef = v.get_method(self, ittype, "key", false) if keydef == null then - v.error(self, "Type Error: Expected method 'key' in Iterator type {ittype}") + v.error(self, "Type Error: 'for' expects a method 'key' in 'Iterator' type {ittype}.") return end self.method_key = keydef.mproperty