syntax: try to produce an error message for local property conflict
authorJean Privat <jean@pryen.org>
Fri, 3 Feb 2012 20:30:49 +0000 (15:30 -0500)
committerJean Privat <jean@pryen.org>
Fri, 3 Feb 2012 21:27:28 +0000 (16:27 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/syntax/mmbuilder.nit
tests/sav/error_prop_loc.sav
tests/sav/module_2.fail [deleted file]
tests/sav/module_2.sav [new file with mode: 0644]
tests/sav/test_inheritance_raf.fail [deleted file]
tests/sav/test_inheritance_raf.sav [new file with mode: 0644]

index 0934d7f..20fb090 100644 (file)
@@ -21,6 +21,23 @@ package mmbuilder
 
 import syntax_base
 
+redef class ToolContext
+       redef fun handle_property_conflict(lc, impls)
+       do
+               var location: nullable Location = null
+               if lc isa MMSrcLocalClass then
+                       var node = lc.node
+                       if node != null then node.location
+               end
+               #if location == null then location = lc.mmmodule.location
+               var clas = new Array[MMLocalClass]
+               for i in impls do
+                       clas.add(i.local_class)
+               end
+               self.fatal_error(location, "Property inheritance conflict in class {lc} for `{impls.first.name}': conflicting properties are defined in {clas.join(", ")}")
+       end
+end
+
 # Class specialization hierarchy sorter
 private class CSHSorter
        super AbstractSorter[MMLocalClass]
index c63d0ac..6a6e994 100644 (file)
@@ -1 +1 @@
-Fatal error: inherit_local_property error
+Property inheritance conflict in class D for `toto': conflicting properties are defined in B, C
diff --git a/tests/sav/module_2.fail b/tests/sav/module_2.fail
deleted file mode 100644 (file)
index c63d0ac..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Fatal error: inherit_local_property error
diff --git a/tests/sav/module_2.sav b/tests/sav/module_2.sav
new file mode 100644 (file)
index 0000000..b603ae7
--- /dev/null
@@ -0,0 +1 @@
+Property inheritance conflict in class C for `a123': conflicting properties are defined in B, A
diff --git a/tests/sav/test_inheritance_raf.fail b/tests/sav/test_inheritance_raf.fail
deleted file mode 100644 (file)
index c63d0ac..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Fatal error: inherit_local_property error
diff --git a/tests/sav/test_inheritance_raf.sav b/tests/sav/test_inheritance_raf.sav
new file mode 100644 (file)
index 0000000..a007f82
--- /dev/null
@@ -0,0 +1 @@
+Property inheritance conflict in class B for `i': conflicting properties are defined in B, A