From 0deeeadb43a25ac447e4b2276e75bf42607f66ef Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 31 Jul 2014 09:01:28 -0400 Subject: [PATCH 1/1] check_annotation: warn if a module declares again annotation Signed-off-by: Jean Privat --- src/check_annotation.nit | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/check_annotation.nit b/src/check_annotation.nit index 38b179f..8641e27 100644 --- a/src/check_annotation.nit +++ b/src/check_annotation.nit @@ -51,14 +51,23 @@ private class CheckAnnotationPhase # Get all the new annotations var annots = nmoduledecl.get_annotations("new_annotation") + var super_mmodules = declared_annotations.lookup_all_modules(mmodule, private_visibility) + # Add each new annotations in the map for annot in annots do var name = annot.arg_as_id(modelbuilder) if name == null then continue + for m in super_mmodules do + if declared_annotations[m].has(name) then + modelbuilder.warning(annot, "Warning: an annotation `{name}` is already declared in module `{m}`") + break label + end + end + declared_annotations[mmodule].add(name) #annot.debug "add {mmodule}: {name}" - end + end label end # Raw new-line separated list of primitive annotation -- 1.7.9.5