antlr / antlr/stringtemplate4

Cloning template multiple times leads to change of attribute type

Open
#100 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1k
Forks
234
PR merge metrics
No merged PRs in 30d

Description

When cloning a template at least two times, the type of an attribute changes to AttributeList.

Below you can find a simple test-case:

``` java
ST t1 = new ST("$key$");

ST t2 = new ST(t1);
t2.add("key1", "value1");
t2.add("key2", "value2");
assertFalse(t2.getAttribute("key1") instanceof AttributeList);

ST t3 = new ST(t1);
t3.add("key1", "value1");
t3.add("key2", "value2");
assertFalse(t3.getAttribute("key1") instanceof AttributeList);
```

I had some issues with this in my templates, so for now I'm using

``` java
templateGroupDir.getInstanceOf(templateName);
```

to create a new instance of a template instead of cloning.

I have expected these two approaches to lead to identical results. Is my expectation wrong?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.