Commit e6f23928 authored by John van Groningen's avatar John van Groningen

improve error message in case an instance or generic derived class instances...

improve error message in case an instance or generic derived class instances are both defined and imported
parent 9c913062
......@@ -3,6 +3,7 @@ implementation module checksupport
import StdEnv, compare_constructor
import syntax, predef, containers
import utilities
from genericsupport import type_cons_to_string
cUndef :== -1
......@@ -318,7 +319,29 @@ addSymbol yes_for_icl_module ident pos decl_kind def_kind def_index def_mod impo
cs & cs_error = checkError ident ("multiply defined (in module "+++toString dcl_name1+++" and already in module "+++toString dcl_name2+++")") cs_error
= (False, dcl_modules, cs)
add_indirectly_imported_symbol _ entry ident pos def_kind def_index def_mod _ dcl_modules cs=:{cs_error}
= (False, dcl_modules, { cs & cs_error = checkError ident "multiply defined" cs_error})
= case decl_kind of
STE_Imported ste_kind mod_index
| mod_index>=0 && mod_index<size dcl_modules
# ({dcl_name,dcl_common={com_gencase_defs}},dcl_modules) = dcl_modules![mod_index]
-> case (ste_kind,entry) of
(STE_GenericDeriveClass,{ste_kind=STE_GenericDeriveClass,ste_index})
| ste_index>=0 && ste_index<size com_gencase_defs
# gc_type_cons = com_gencase_defs.[ste_index].gc_type_cons
# ident = "derived generic instances for class "+++ident.id_name+++" for type "+++type_cons_to_string gc_type_cons
-> (False, dcl_modules, {cs & cs_error = checkError ident ("multiply defined (also imported from module "+++toString dcl_name+++")") cs_error})
(STE_Instance,{ste_kind=STE_Instance,ste_index})
-> (False, dcl_modules, {cs & cs_error = checkError ("instance of class "+++toString ident) ("multiply defined (also imported from module "+++toString dcl_name+++")") cs_error})
_
-> (False, dcl_modules, {cs & cs_error = checkError ident ("multiply defined (also imported from module "+++toString dcl_name+++")") cs_error})
_
# cs_error = case entry.ste_kind of
STE_GenericDeriveClass
-> checkError ("derive of class "+++toString ident) "multiply defined" cs_error
STE_Instance
-> checkError ("instance of class "+++toString ident) "multiply defined" cs_error
_
-> checkError ident "multiply defined" cs_error
-> (False, dcl_modules, {cs & cs_error=cs_error})
addGlobalDefinitionsToSymbolTable :: ![Declaration] !*CheckState -> .CheckState;
addGlobalDefinitionsToSymbolTable decls cs
......
......@@ -50,6 +50,7 @@ postfixIdent :: !String !String -> Ident
genericIdentToClassIdent :: !String !TypeKind -> Ident
genericIdentToMemberIdent :: !String !TypeKind -> Ident
genericIdentToFunIdent :: !String !TypeCons -> Ident
type_cons_to_string :: !TypeCons -> {#Char}
kind_to_short_string :: !TypeKind -> {#Char}
field_n_of_GenericTypeDefDescriptor :: !String -> Int
......
......@@ -99,13 +99,14 @@ genericIdentToMemberIdent id_name kind
genericIdentToFunIdent :: !String !TypeCons -> Ident
genericIdentToFunIdent id_name type_cons
= postfixIdent id_name ("_" +++ type_cons_to_str type_cons)
where
type_cons_to_str (TypeConsSymb {type_ident}) = toString type_ident
type_cons_to_str (TypeConsBasic bt) = toString bt
type_cons_to_str TypeConsArrow = "ARROW"
type_cons_to_str (TypeConsVar tv) = tv.tv_ident.id_name
type_cons_to_str (TypeConsQualifiedIdent _ type_name) = type_name
= postfixIdent id_name ("_" +++ type_cons_to_string type_cons)
type_cons_to_string :: !TypeCons -> {#Char}
type_cons_to_string (TypeConsSymb {type_ident}) = toString type_ident
type_cons_to_string (TypeConsBasic bt) = toString bt
type_cons_to_string TypeConsArrow = "ARROW"
type_cons_to_string (TypeConsVar tv) = tv.tv_ident.id_name
type_cons_to_string (TypeConsQualifiedIdent _ type_name) = type_name
field_n_of_GenericTypeDefDescriptor :: !String -> Int
field_n_of_GenericTypeDefDescriptor "gtd_name" = 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment