[ClavaAst] InitListExpr.getCode() avoid syntatic form is custom names
@@ -78,8 +78,18 @@ public class InitListExpr extends Expr {
InitListExpr syntaticForm = get(SYNTACTIC_FORM).orElse(null);
if (syntaticForm != null) {
if (!syntaticForm.getId().equals(getId())) {
+
+ // If there are varrefs with custom names, cannot use syntatic form
+ var hasCustomNames = getDescendantsStream()
+ .filter(node -> node instanceof DeclRefExpr && node.hasValue(DeclRefExpr.CUSTOM_NAME))
+ .findFirst().isPresent();
+
+ // System.out.println("SYN FORM: " + syntaticForm.getCode());
+ if (!hasCustomNames) {
return syntaticForm.getCode();
}
+
+ }
}
String list = getChildren().stream()
