'test'.Substring(1) = 'something'
At line:1 char:1
+ 'test'.Substring(1) = 'something'
+ ~~~~~~~~~~~~~~~~~~~
The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as
a variable or a property.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidLeftHandSide
Nothing, it works like if the LHS was $null
.
Name Value
---- -----
PSVersion 7.1.0-preview.5
PSEdition Core
GitCommitId 7.1.0-preview.5
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Tbh I don't really want this fixed because it frees me up to maybe implement some ref return stuff in PSLambda. That's not really a valid reason though, so reporting anyway.
My guess is this is because MemberExpressionAst
implements ISupportsAssignment
, but just doesn't check if it happens to be an InvokeMemberExpressionAst
instance.
As I recall, this is intentional support for assignment to byref return values which, while not common, are used in some important VBA scenarios.
@lzybkr can you give an example of how that would look? I'm having trouble picturing what that would be useful for 馃槀
Oh right like $excelWorkSheet.Cells.Item(1, 1) = 'text'
. So then I guess the question is should it throw if the com binder isn't used?
Or should support just be added to the CLR binder? As long as the invocation is on the LHS and not saved it should be doable.
This kind of brings up a bigger discussion that might be better off in a new issue but:
Though the above questions are made a bit more complicated by the fact that there's very limited support for them in the SLE.Expression
API.
Most helpful comment
This kind of brings up a bigger discussion that might be better off in a new issue but:
Though the above questions are made a bit more complicated by the fact that there's very limited support for them in the
SLE.Expression
API.