Skip to content

Commit 12a376a

Browse files
committed
Fix reference to derived_type_sym in FunctionType
1 parent 7e67c83 commit 12a376a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/libasr/asdl_cpp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,8 @@ def visitField(self, field):
13031303
self.emit(" self().replace_expr(x->m_%s[i]);"%(field.name), level)
13041304
self.emit(" current_expr = current_expr_copy_%d;" % (self.current_expr_copy_variable_count), level)
13051305
self.current_expr_copy_variable_count += 1
1306+
elif field.type == "ttype":
1307+
self.emit(" self().replace_%s(x->m_%s[i]);" % (field.type, field.name), level)
13061308
self.emit("}", level)
13071309
else:
13081310
if field.type != "symbol":

src/libasr/asr_utils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,16 @@ class ReplaceWithFunctionParamVisitor: public ASR::BaseExprReplacer<ReplaceWithF
32773277
}
32783278
}
32793279

3280+
void replace_Struct(ASR::Struct_t *x) {
3281+
std::string derived_type_name = ASRUtils::symbol_name(x->m_derived_type);
3282+
ASR::symbol_t* derived_type_sym = current_scope->resolve_symbol(derived_type_name);
3283+
LCOMPILERS_ASSERT_MSG( derived_type_sym != nullptr,
3284+
"derived_type_sym cannot be nullptr");
3285+
if (derived_type_sym != x->m_derived_type) {
3286+
x->m_derived_type = derived_type_sym;
3287+
}
3288+
}
3289+
32803290
ASR::ttype_t* replace_args_with_FunctionParam(ASR::ttype_t* t, SymbolTable* current_scope) {
32813291
this->current_scope = current_scope;
32823292

0 commit comments

Comments
 (0)