Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使子表达式是平衡的,Powershell也会报告MissingendBranchisinexpression_Powershell - Fatal编程技术网

即使子表达式是平衡的,Powershell也会报告MissingendBranchisinexpression

即使子表达式是平衡的,Powershell也会报告MissingendBranchisinexpression,powershell,Powershell,下面是我的子表达式: """$((($l -split " """)[1] -split """ ")[0])""" 我检查了一下,没有发现不成对的括号。然而,powershell坚持在表达式中使用“缺少结尾”) 有趣的是 $((($l -split " """)[1] -split """ ")[0]) 很好 以前有人有过类似的经历吗?这是Powershell的bug吗?这。。真的很有趣,是的,至少我认为它是一个bug。 这里有一个更简单的复制: "$("`"")" "$(

下面是我的子表达式:

    """$((($l -split " """)[1] -split """ ")[0])"""
我检查了一下,没有发现不成对的括号。然而,powershell坚持在表达式中使用“缺少结尾”) 有趣的是

    $((($l -split " """)[1] -split """ ")[0])
很好


以前有人有过类似的经历吗?这是Powershell的bug吗?

这。。真的很有趣,是的,至少我认为它是一个bug。 这里有一个更简单的复制:

"$("`"")"
"$("""")"
这似乎是由于在子表达式内部、可扩展字符串内部使用了任意形式的双引号转义(backtick或double-double-quote)

这似乎也是一个错误,它直接影响到解析器本身:

$sb = @'
"$("`"")"
'@

$tokens = $null
$er = $null

$ast = [System.Management.Automation.Language.Parser]::ParseInput($sb, [ref]$tokens, [ref]$er)

$ast.EndBlock.Statements[0].PipelineElements[0].Expression.NestedExpressions

$tokens[0].NestedTokens
它找到的嵌套标记/表达式不正确

我在WLS上使用Windows PowerShell 5.1和PowerShell Core 6.0.0-rc.2进行了测试

相关问题

非常感谢您,@briantist。我怀疑,但你证明得很有说服力。