File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,8 +234,15 @@ def statement(self) -> AST.Statement | None:
234234
235235 self .consume (TokenType .RBRACKET , 'Expected "]" in destructuring pattern' )
236236 if self .check (TokenType .ASSIGN ):
237- self .advance ()
238- return self .destructuring_assignment (names , variables , start )
237+ assign_token = self .advance ()
238+ if assign_token .value == "=" :
239+ return self .destructuring_assignment (names , variables , start )
240+ self .report_error (
241+ 'Tuple destructuring uses "=" only. Reassignment with ":=" is not valid in Pine Script.' ,
242+ assign_token ,
243+ )
244+ self .expression ()
245+ return None
239246 self .current = checkpoint
240247 except Exception :
241248 self .current = checkpoint
Original file line number Diff line number Diff line change @@ -153,9 +153,14 @@ def test_strategy_negative_pyramiding_is_rejected(self) -> None:
153153 )
154154 )
155155
156- def test_destructuring_reassignment_is_supported (self ) -> None :
156+ def test_destructuring_reassignment_is_rejected (self ) -> None :
157157 diagnostics = self .validator .validate_text ("[a, b] := foo()" )
158- self .assertFalse (any ("Mismatched input" in diagnostic .message for diagnostic in diagnostics ))
158+ self .assertTrue (
159+ any (
160+ 'Tuple destructuring uses "=" only. Reassignment with ":=" is not valid in Pine Script.' in diagnostic .message
161+ for diagnostic in diagnostics
162+ )
163+ )
159164
160165 def test_typed_array_declaration (self ) -> None :
161166 diagnostics = self .validator .validate_text ("var box[] mc_boxes = array.new_box()" )
You can’t perform that action at this time.
0 commit comments