fixed type check issues with records as params

This commit is contained in:
Partho
2025-04-14 12:33:52 -04:00
parent 5c6ab34518
commit f2db338257
2 changed files with 17 additions and 13 deletions

View File

@ -208,32 +208,37 @@ definition:
}
}
} else {
printdebug("record found");
for (TableNode* entry = getFirstEntry(getRecList(parameter)); entry!= NULL; entry = getNextEntry(entry)){
int type_of_param_type = getAdInfoType(entry);
if( type_of_param_type == TYPE_UNDEFINED
|| type_of_param_type == TYPE_FUNCTION_DECLARATION
|| type_of_param_type == TYPE_ARRAY
|| type_of_param_type == TYPE_PRIMITIVE
|| type_of_param_type == TYPE_FUNCTION_TYPE
|| type_of_param_type == TYPE_ARRAY_TYPE
|| type_of_param_type == TYPE_PRIMITIVE_TYPE
|| type_of_param_type == TYPE_ALL_ELSE
|| type_of_param_type == TYPE_SYSTEM_DEFINED
|| type_of_param_type == TYPE_RECORD
|| type_of_param_type == TYPE_RECORD_TYPE
|| type_of_param_type == TYPE_STRING){ // note that strings are actually arrays so this is unused
printdebug("[TYPE CHECK] type of parameter (if record) inside record being passed in to function definition is %s which is invalid", getAdInfo(parameter));
printdebug("[TYPE CHECK] type of parameter (if record) inside record being passed in to function definition is %s which is invalid", getType(entry));
type_of_param_type = TYPE_UNDEFINED; // setting tag as undefined in these cases
}else{
printdebug("type of parameter correctly being passed in to AS function definition is %s which is valid", getName(entry));
printdebug("type of parameter correctly being passed in to AS function definition is %s which is valid", getType(entry));
}
if(type_of_param_type == TYPE_UNDEFINED){
printdebug("undefined type of parameter inside record");
CreateEntry(cur,type_of_param_type, undefined, NULL, NULL);
} else {
if(type_of_param_type == TYPE_FUNCTION_TYPE){
CreateEntry(cur, TYPE_FUNCTION_DECLARATION, entry,NULL, getAdInfo(entry));
if(type_of_param_type == TYPE_FUNCTION_DECLARATION){
printdebug("function declaration of parameter inside record");
CreateEntry(cur, TYPE_FUNCTION_DECLARATION, getTypeEntry(entry),NULL, getAdInfo(entry));
}
if(type_of_param_type == TYPE_ARRAY_TYPE){
CreateEntry(cur, TYPE_ARRAY, entry,NULL, getAdInfo(entry));
if(type_of_param_type == TYPE_ARRAY){
printdebug("array type of parameter inside record");
CreateEntry(cur, TYPE_ARRAY, getTypeEntry(entry),NULL, getAdInfo(entry));
}
if(type_of_param_type == TYPE_PRIMITIVE_TYPE){
CreateEntry(cur, TYPE_PRIMITIVE, entry,NULL, getAdInfo(entry));
if(type_of_param_type == TYPE_PRIMITIVE){
printdebug("primitive type of parameter inside record");
CreateEntry(cur, TYPE_PRIMITIVE, getTypeEntry(entry),NULL, getAdInfo(entry));
}
/*printdebug("creating entry of type %s for function", getType(entry));
CreateEntry(cur, getTypeEntry(entry), "undefined", NULL);*/

View File

@ -48,7 +48,6 @@ foo (x) := {
}
bar1(a,b) := {
[integer : t]
return a * b;
}