@@ -1014,7 +1014,7 @@ func (c *compiler) compileFunc(e *Func) error {
10141014// Appends the compiled code for the assignment operator (`=`) to maximize 
10151015// performance. Originally the operator was implemented as follows. 
10161016// 
1017- //	def _assign(p; $x): reduce path(p) as $p  (.; setpath($p ; $x)); 
1017+ //	def _assign(p; $x): reduce path(p) as $q  (.; setpath($q ; $x)); 
10181018// 
10191019// To overcome the difficulty of reducing allocations on `setpath`, we use the 
10201020// `allocator` type and track the allocated addresses during the reduction. 
@@ -1023,8 +1023,9 @@ func (c *compiler) compileAssign() {
10231023	scope  :=  c .newScope ()
10241024	v , p  :=  [2 ]int {scope .id , 0 }, [2 ]int {scope .id , 1 }
10251025	x , a  :=  [2 ]int {scope .id , 2 }, [2 ]int {scope .id , 3 }
1026+ 	q  :=  [2 ]int {scope .id , 4 } // Cannot reuse p due to backtracking in x. 
10261027	c .appends (
1027- 		& code {op : opscope , v : [3 ]int {scope .id , 4 , 2 }},
1028+ 		& code {op : opscope , v : [3 ]int {scope .id , 5 , 2 }},
10281029		& code {op : opstore , v : v }, //                def _assign(p; $x): 
10291030		& code {op : opstore , v : p },
10301031		& code {op : opstore , v : x },
@@ -1044,10 +1045,10 @@ func (c *compiler) compileAssign() {
10441045		& code {op : opcallpc },
10451046		& code {op : opload , v : v },
10461047		& code {op : oppathend },
1047- 		& code {op : opstore , v : p }, //                as $p  (.; 
1048- 		& code {op : opload , v : a },  //                setpath($p ; $x) 
1048+ 		& code {op : opstore , v : q }, //                as $q  (.; 
1049+ 		& code {op : opload , v : a },  //                setpath($q ; $x) 
10491050		& code {op : opload , v : x },
1050- 		& code {op : opload , v : p },
1051+ 		& code {op : opload , v : q },
10511052		& code {op : opload , v : v },
10521053		& code {op : opcall , v : [3 ]interface {}{funcSetpathWithAllocator , 3 , "_setpath" }},
10531054		& code {op : opstore , v : v },
0 commit comments