Skip to content

Commit

Permalink
- Custom error message when failing to elaborate a metarecord call
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 14, 2010
1 parent 3082d62 commit cdaaf77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Compiler/Error.mo
Expand Up @@ -270,6 +270,7 @@ public constant ErrorID META_MATCHEXP_RESULT_NUM_ARGS=5007;
public constant ErrorID META_CEVAL_FUNCTION_REFERENCE=5008;
public constant ErrorID NON_INSTANTIATED_FUNCTION=5009;
public constant ErrorID META_UNSOLVED_POLYMORPHIC_BINDINGS=5010;
public constant ErrorID META_RECORD_FOUND_FAILURE=5011;

protected constant list<tuple<Integer, MessageType, Severity, String>> errorTable=
{(SYNTAX_ERROR,SYNTAX(),ERROR(),"Syntax error near: %s"),
Expand Down Expand Up @@ -611,7 +612,8 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl
(META_CEVAL_FUNCTION_REFERENCE,TRANSLATION(),ERROR(),"Cannot evaluate function pointers (got %s)."),
(NON_INSTANTIATED_FUNCTION,SYMBOLIC(),ERROR(),"Tried to use function %s, but it was not instantiated."),
(GENERIC_INST_FUNCTION,TRANSLATION(),ERROR(),"Failed to instantiate function %s in scope %s"),
(META_UNSOLVED_POLYMORPHIC_BINDINGS,TRANSLATION(),ERROR(),"Could not solve the polymorphism in the function call\n Input bindings: %s\n Solved bindings: %s\n Unsolved bindings: %s")
(META_UNSOLVED_POLYMORPHIC_BINDINGS,TRANSLATION(),ERROR(),"Could not solve the polymorphism in the function call\n Input bindings: %s\n Solved bindings: %s\n Unsolved bindings: %s"),
(META_RECORD_FOUND_FAILURE,TRANSLATION(),ERROR(),"Found %s with type %s, but failed to elaborate the call.")

};

Expand Down
13 changes: 11 additions & 2 deletions Compiler/Static.mo
Expand Up @@ -8732,7 +8732,7 @@ algorithm
equation
true = RTOpts.acceptMetaModelicaGrammar();
false = Util.getStatefulBoolean(stopElab);
(cache,t as (DAE.T_METARECORD(index,vars),_),env_1) = Lookup.lookupType(cache, env, fn, false);
(cache,t as (DAE.T_METARECORD(index,vars),SOME(fqPath)),env_1) = Lookup.lookupType(cache, env, fn, false);
Util.setStatefulBoolean(stopElab,true);
//(cache,c,env_1) = Lookup.lookupClass(cache, env, fn, false);
// (_, _, _, _, (DAE.T_COMPLEX(complexClassType = ClassInf.META_RECORD(_), complexVarLst = vars),_), _, _, _) = Inst.instClass(cache,env_1,DAE.NOMOD(),Prefix.NOPRE(), Connect.emptySet,c,{},false,Inst.INNER_CALL(), ConnectionGraph.EMPTY);
Expand All @@ -8747,11 +8747,20 @@ algorithm
true = Util.listFold(newslots, slotAnd, true);
//(cache,newslots2) = fillDefaultSlots(cache,newslots, c, env, impl,pre,info);
args_2 = expListFromSlots(newslots);
(cache, fqPath) = Inst.makeFullyQualified(cache, env_1, fn);
then
(cache,DAE.METARECORDCALL(fqPath,args_2,fieldNames,index),prop,Util.SUCCESS());
/* ------ */

/* MetaRecord failure */
case (cache,env,fn,args,nargs,impl,stopElab,st,pre,info)
equation
true = RTOpts.acceptMetaModelicaGrammar();
true = Util.getStatefulBoolean(stopElab);
(cache,t as (DAE.T_METARECORD(index,vars),SOME(fn_1)),env_1) = Lookup.lookupType(cache, env, fn, false);
types_str = Types.unparseType(t);
fn_str = Absyn.pathString(fn_1);
Error.addSourceMessage(Error.META_RECORD_FOUND_FAILURE,{fn_str,types_str},info);
then (cache,DAE.ICONST(0),DAE.PROP((DAE.T_NOTYPE(),NONE()),DAE.C_VAR),Util.FAILURE());
case (cache,env,fn,args,nargs,impl,stopElab,st,pre,info) /* ..Other functions */
local
DAE.ExpType tp;
Expand Down

0 comments on commit cdaaf77

Please sign in to comment.