You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using ST04 with great pleasure :)
Today I found a behaviour, where ST4.0.8 renders output, which I can't explain. Is it intended to do so?
I would expect an deffensive error message, saying that parameter "a" has beend specified twice.
(Sure, this error does not occur, when I don't repeat the parameter literals in the list of parameters. It's more a question of robustness, fail safety, etc.)
My example:
packagede.hartmutpfarr.bmj.test;
importstaticorg.assertj.core.api.Assertions.assertThat;
importorg.junit.Test;
importorg.stringtemplate.v4.ST;
importorg.stringtemplate.v4.STGroup;
importorg.stringtemplate.v4.STGroupString;
publicclassStringTemplateTest {
@TestpublicvoidtestName() throwsException {
// intention has been:// main(a,b,c)// by mistake, human failure, etc., specify parameter "a" twice:// main(a,b,a,c)Stringtempl = "main(a,b,a,c) ::= <<START <a>, <b>, <c> END>>";
STGroupgroup = newSTGroupString(templ);
STst = group.getInstanceOf("main");
st.add("a", "A");
st.add("b", "B");
st.add("c", "C");
assertThat(st.render()).isEqualTo("START A, B, C END");
// org.junit.ComparisonFailure:// expected: <"START A, B, C END">// but was: <"START AC, B, AC END">
}
}
Kind regards!
The text was updated successfully, but these errors were encountered:
Welcome to the project, and thanks for taking the time to report this (and even include sample code) ✨
This should definitely not be allowed. We'll have to think about the specific way we want to handle this, and also examine related issues regarding like manual definition of templates and signature mismatches that may occur when importing templates.
StringTemplate is moving on a pretty slow release cycle, mostly due to an absence of bug reports (not a bad thing when you think about it). I've marked this for inclusion in the next patch release. If we don't get it out the door fast enough and it continues to bother you, please don't hesitate to post a reminder here. 👍
sharwell
added a commit
to sharwell/stringtemplate4
that referenced
this issue
Jul 17, 2016
I am using ST04 with great pleasure :)
Today I found a behaviour, where ST4.0.8 renders output, which I can't explain. Is it intended to do so?
I would expect an deffensive error message, saying that parameter "a" has beend specified twice.
(Sure, this error does not occur, when I don't repeat the parameter literals in the list of parameters. It's more a question of robustness, fail safety, etc.)
My example:
Kind regards!
The text was updated successfully, but these errors were encountered: