From 257fdfb19b87599c7ad7186fc8c529236f001ae0 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 3 Feb 2012 15:30:49 -0500 Subject: [PATCH] syntax: try to produce an error message for local property conflict Signed-off-by: Jean Privat --- src/syntax/mmbuilder.nit | 17 +++++++++++++++++ tests/sav/error_prop_loc.sav | 2 +- tests/sav/module_2.fail | 1 - tests/sav/module_2.sav | 1 + tests/sav/test_inheritance_raf.fail | 1 - tests/sav/test_inheritance_raf.sav | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) delete mode 100644 tests/sav/module_2.fail create mode 100644 tests/sav/module_2.sav delete mode 100644 tests/sav/test_inheritance_raf.fail create mode 100644 tests/sav/test_inheritance_raf.sav diff --git a/src/syntax/mmbuilder.nit b/src/syntax/mmbuilder.nit index 0934d7f..20fb090 100644 --- a/src/syntax/mmbuilder.nit +++ b/src/syntax/mmbuilder.nit @@ -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] diff --git a/tests/sav/error_prop_loc.sav b/tests/sav/error_prop_loc.sav index c63d0ac..6a6e994 100644 --- a/tests/sav/error_prop_loc.sav +++ b/tests/sav/error_prop_loc.sav @@ -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 index c63d0ac..0000000 --- a/tests/sav/module_2.fail +++ /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 index 0000000..b603ae7 --- /dev/null +++ b/tests/sav/module_2.sav @@ -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 index c63d0ac..0000000 --- a/tests/sav/test_inheritance_raf.fail +++ /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 index 0000000..a007f82 --- /dev/null +++ b/tests/sav/test_inheritance_raf.sav @@ -0,0 +1 @@ +Property inheritance conflict in class B for `i': conflicting properties are defined in B, A -- 1.7.9.5