[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Claude Brisson (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024549#comment-17024549
 ] 

Claude Brisson edited comment on VELOCITY-926 at 1/28/20 6:40 AM:
--

When a naming collision occurs, there is a side effect which is that in 1.7, 
global context values become default values for *missing* macro arguments.

Two people reported usecases where backward compatibility was broken because of 
this 1.7 _undocumented feature_, so it's worth addressing.

The plan is to deprecate the 2.1 flag 
{{velocimacro.arguments.preserve_literals}} in favor of a new 
{{velocimacro.enable_bc_mode}} flag which would :
 * preserve arguments literals
 * allow global values as defaults for missing arguments
 * -also allow a macro to set to null a reference in the global context by 
setting one of its arguments to null (setting a global reference this way is 
allowed in 2.x but not for null values)- (let's leave out this one and revert 
the _standard_ behavior to also allow setting nulls by default, it was just a 
side effect of fixing VELOCITY-904 with commit 1871332)
 



was (Author: claude):
When a naming collision occurs, there is a side effect which is that in 1.7, 
global context values become default values for *missing* macro arguments.

Two people reported usecases where backward compatibility was broken because of 
this 1.7 _undocumented feature_, so it's worth addressing.

The plan is to deprecate the 2.1 flag 
{{velocimacro.arguments.preserve_literals}} in favor of a new 
{{velocimacro.enable_bc_mode}} flag which would :

* preserve arguments literals
* allow global values as defaults for missing arguments
* also allow a macro to set to null a reference in the global context by 
setting one of its arguments to null (setting a global reference this way is 
allowed in 2.x but not for null values)






> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024437#comment-17024437
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/27/20 3:47 PM:
---

bq. global values provide defaults for missing arguments

Sounds good to me. It would be enough to cover 
https://issues.apache.org/jira/browse/VELOCITY-926?focusedCommentId=17023076=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17023076.

Even if it does not cover the other use cases discussed on the mailing list 
regarding the macro local context it's still  better than nothing (at least we 
can say "hey it's Velocity's fault, we tried" and have a good excuse to have a 
simpler behavior ;)).


was (Author: tmortagne):
bq. global values provide defaults for missing arguments

Sounds good to me. It would be enough to cover 
https://issues.apache.org/jira/browse/VELOCITY-926?focusedCommentId=17023076=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17023076.

Even if it does not cover the other use cases discussed on the mailing list 
regarding the macro local context it's still  better than nothing.

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024437#comment-17024437
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/27/20 3:39 PM:
---

bq. global values provide defaults for missing arguments

Sounds good to me. It would be enough to cover 
https://issues.apache.org/jira/browse/VELOCITY-926?focusedCommentId=17023076=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17023076.

Even if it does not cover the other use cases discussed on the mailing list 
regarding the macro local context it's still  better than nothing.


was (Author: tmortagne):
bq. global values provide defaults for missing arguments

Sounds good to me. It would be enough to cover 
https://issues.apache.org/jira/browse/VELOCITY-926?focusedCommentId=17023076=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17023076.

Even if it does not cover the other use cases discussed on the mailing list 
regarding the macro local context it's better still  better than nothing.

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024342#comment-17024342
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/27/20 1:46 PM:
---

bq. That's why I was asking for a specific use case

What I can tell you is that we did fixed several codes in XWiki Standard doing 
that but I agree with you that it was mistakes in both cases. So yes I don't 
have a strong use case to describe but any weird behavior always end up being 
expected and used in 10 years :) From what I understand the reason for this 
behavior in 1.7 is a side effect of the local macro context (the macro 
parameter being null the local context but variables were also fallbacking to 
global context when unset) which does not exist anymore and I guess it not 
really easy to get back this behavior without getting back the local macro 
context which you said you did not wanted anymore even as a retro compatible 
option.


was (Author: tmortagne):
bq. That's why I was asking for a specific use case

What I can tell you is that we did fixed several codes in XWiki Standard doing 
that but I agree with you that it was mistakes in both cases. So yes I don't 
have a strong use case to describe but any weird behavior always end up being 
expected and used in 10 years :) From what I understand the reason for this 
behavior in 1.7 is a side effect of the local macro context (the macro 
parameter being unset in the local context but variables were also fallbacking 
to global context when unset) which does not exist anymore and I guess it not 
really easy to get back this behavior without getting back the local macro 
context which you said you did not wanted anymore even as a retro compatible 
option.

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024342#comment-17024342
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/27/20 1:39 PM:
---

bq. That's why I was asking for a specific use case

What I can tell you is that we did fixed several codes in XWiki Standard doing 
that but I agree with you that it was mistakes in both cases. So yes I don't 
have a strong use case to describe but any weird behavior always end up being 
expected and used in 10 years :) From what I understand the reason for this 
behavior in 1.7 is a side effect of the local macro context (the macro 
parameter being unset in the local context but variables were also fallbacking 
to global context when unset) which does not exist anymore and I guess it not 
really easy to get back this behavior without getting back the local macro 
context which you said you did not wanted anymore even as a retro compatible 
option.


was (Author: tmortagne):
bq. That's why I was asking for a specific use case

What I can tell you is that we did fixed several codes in XWiki Standard doing 
that but I agree with you that it was mistakes in both cases. So yes I don't 
have a strong use case to describe but any weird behavior always end up being 
expected and used in 10 years :) From what I understand the reason for this 
behavior in 1.7 is a side effect of the local macro context which does not 
exist anymore and I guess it not really easy to get back this behavior without 
getting back the local macro context which you said you did not wanted anymore 
even as a retro compatible option.

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17024342#comment-17024342
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/27/20 1:38 PM:
---

bq. That's why I was asking for a specific use case

What I can tell you is that we did fixed several codes in XWiki Standard doing 
that but I agree with you that it was mistakes in both cases. So yes I don't 
have a strong use case to describe but any weird behavior always end up being 
expected and used in 10 years :) From what I understand the reason for this 
behavior in 1.7 is a side effect of the local macro context which does not 
exist anymore and I guess it not really easy to get back this behavior without 
getting back the local macro context which you said you did not wanted anymore 
even as a retro compatible option.


was (Author: tmortagne):
bq. That's why I was asking for a specific use case

What I can tell you is that we did fixed several codes in XWiki Standard doing 
that but I agree with you that it was mistakes in both cases. So yes I don't 
have a strong use case to describe but any weird behavior always end up being 
expected and used in 10 years :)

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-27 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17023076#comment-17023076
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/27/20 8:00 AM:
---

Seems this had a side effect:

The following:

{code}
#macro (myMacro $myvar)
  $myvar
#end

#set ($myvar = "value")
#myMacro()
{code}

produces:

* Before VELOCITY-926 and in 1.7: "value"
* After VELOCITY-926: $myvar


was (Author: tmortagne):
Seems this had a side effect:

The following:

{code}
#macro (myMacro $myvar)
  $myvar
#end

#set ($myvar = "value")
#myMacro()
{code}

produces:

* Before VELOCITY-926 and in 1.7: "value"
* After VELOCITY-926: $foobar

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org



[jira] [Comment Edited] (VELOCITY-926) Regression: Macro arguments names cannot collide with external references names

2020-01-24 Thread Thomas Mortagne (Jira)


[ 
https://issues.apache.org/jira/browse/VELOCITY-926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17023139#comment-17023139
 ] 

Thomas Mortagne edited comment on VELOCITY-926 at 1/24/20 5:46 PM:
---

bq. Could you give me an example where the former behavior would be important 
for backward compatibility?

Any change is important for backward compatibility. As usual I'm not discussing 
how valid this behavior is but the fact that this behavior is expected and will 
break things.


was (Author: tmortagne):
bq. Could you give me an example where the former behavior would be important 
for backward compatibility?

Any change is important for backward compatibility. As usuall I'm not 
discussing how valid this behavior is but the fact that this behavior is 
expected and will break things.

> Regression: Macro arguments names cannot collide with external references 
> names
> ---
>
> Key: VELOCITY-926
> URL: https://issues.apache.org/jira/browse/VELOCITY-926
> Project: Velocity
>  Issue Type: Bug
>  Components: Engine
>Affects Versions: 2.0, 2.1
>Reporter: Claude Brisson
>Assignee: Claude Brisson
>Priority: Major
> Fix For: 2.2
>
>
> Consider the following example:
> {code}
> #macro( test $foo $bar )
>   $foo $bar
> #end
> #set($foo = 'foo')
> #set($bar = 'bar')
> #test( $bar, $foo )
> {code}
> The expected result would be "{{bar foo}}", but since 2.0 we get the 
> incorrect result "{{bar bar}}", as if the first inner {{$foo}} macro argument 
> was overwritting the second argument evaluation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

-
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org