-
Notifications
You must be signed in to change notification settings - Fork 235
REPL loop error, index out of range, must be non negative #1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Somewhere I saw it mentioned that the term was maybe related
It'd be running fine, but, at some point I found it would get stuck -- running cached code instead. I tested it by creating a function that runs. Next I added a function foo {
throw "bad
}
foo |
Maybe the REPL error is a red herring? Maybe it's not exactly a bug, just an error record either getting wrapped or not getting wrapped, so it appears it's a crash? Because Correct Error Just Not Bubbling?It seems to be caused by a legitimate/correct error being thrown, that's getting consumed by [Globalization.CharUnicodeInfo]::GetUnicodeCategory('a')
MethodException: Cannot convert argument "codePoint", with v
alue: "a", for "GetUnicodeCategory" to type "System.Int32":
"Cannot convert value "a" to type "System.Int32". Error: "In
put string was not in a correct format.""
It seems to happen more often under these conditions
Is sampleThis is the code that was triggering the REPL error when inside a module, but not when outside. It's possible the specific code doesn't matter, rather it's any exception thrown ? #Requires -Version 7
using namespace system.Text
function Inspect-Rune {
<#
#>
[CmdletBinding(PositionalBinding = $false)]
param(
# any text
[Parameter(Position = 0, Mandatory, ValueFromPipeline)]
[string]$InputText
)
begin {
$str = @{
Null = '[null]'
NullSymbol = "`u{2400}"
}
$Simplify = $false
}
process {
$InputText.EnumerateRunes()
| ForEach-Object {
$rune = $_
$meta = [ordered]@{
PSTypeName = 'nin.RuneDetail'
CodeHex = '0x{0:x}' -f $Rune.Value
UniCategory = [Rune]::GetUnicodeCategory( $Rune )
}
if ($meta.UniCategory -match 'control' ) {
$meta['Render'] = [rune]::new( $Rune.Value + 0x2400 )
} else {
$meta['Render'] = "'$Rune'"
}
Wait-Debugger
if (!$Simplify) {
$meta += @{
# PwshLiteral = $Rune | ConvertTo-PwshLiteral
CodePoint = $Rune.Value
GI_Category = [Globalization.CharUnicodeInfo]::GetUnicodeCategory( $_.Value )
GI_DecimalDigit = [Globalization.CharUnicodeInfo]::GetDecimalDigitValue( $_.Value )
GI_DigitValue = [Globalization.CharUnicodeInfo]::GetDigitValue( $_.Value )
GI_NumericValue = [Globalization.CharUnicodeInfo]::GetNumericValue( $_.Value )
}
}
[PSCustomObject]$meta
}
}
end {
}
}
'😃' | Inspect-Rune
'👩🏼🦳' | Inspect-Rune |
@ninmonkey Justin and I solved an index out of range exception that was happening, and I resolved the scoping regression by moving back to dot-source instead of ampersand-call. Can you test the latest preview released yesterday to see if these issues have been resolved? Thanks! |
@andschwa I tried the latest insider with both extensions.
Version: 1.64.0-insider
Commit: 753319a08f8e74700b1dba3a29bf0a6af7c2953f I'm getting the (expected) errors, ex:
|
Fantastic, thanks for confirming! |
@andschwa Sadly I just hit this in Pester on v2022.1.0 while debugging. I'll try to get a better repro together. EDIT: Only seems to trigger in debug, non-debug it doesn't happen.
Script UsedDescribe 'ConvertTo-ReliefJetPST' {
BeforeAll {
Import-Module $PSScriptRoot/PSTMigration.psm1 -Force
$SCRIPT:Mocks = Resolve-Path (Join-Path $PSScriptRoot $PSTMigration.Mocks)
}
It 'Folder with MSG files, different destination' {
$MockSource = Join-Path $Mocks 'FolderWithMsgFile'
$MockSource
| ConvertTo-ReliefJetPST -Destination 'TestDrive:/'
}
} |
@JustinGrote That stack traces points to here: Lines 152 to 159 in 149f5ac
Which means somehow |
Actually, @JustinGrote could you please open a new issue instead and close this? The stacktrace you shared indicates a different bug. And test #1670 😀 |
About
Some regular errors are trigging this exception from editor services. The exact same code outside of
vscode
throws a parameter binding error like normal. It seems like there's a regular error, for a failed parameter binding, which is triggering an EditorServices crash/errorNotes or Ideas
ConvertFrom-LiteralPath
, it seems to occur on functions withWrite-Error
, but not all of themvscode PSIT
/w PSES it throws the REPL exceptionwt
throws just the parameter binding error.d:\
, I'm wondering if that's a path to one of the developers ? I have nod:\a\
directoryREPL
error would throwWrite-Error -ea Continue
caused the REPL exception, verses stop or implicit[Exception]
as[int]
normal ?Code
I simplified the cause down to a single
write-error
. It triggered when imported from a module verses dotsourced externally.Expected Behavior
Actual Behavior
Run
Output
Log
Environment
Logs
About
Some regular errors are trigging this exception from editor services. The exact same code outside of
vscode
throws a parameter binding error like normal. It seems like there's a regular error, for a failed parameter binding, which is triggering an EditorServices crash/errorNotes or Ideas
ConvertFrom-LiteralPath
, it seems to occur on functions withWrite-Error
, but not all of themvscode PSIT
/w PSES it throws the REPL exceptionwt
throws just the parameter binding error.d:\
, I'm wondering if that's a path to one of the developers ? I have nod:\a\
directoryREPL
error would throwWrite-Error -ea Continue
caused the REPL exception, verses stop or implicit[Exception]
as[int]
normal ?Code
I simplified the cause down to a single
write-error
. It triggered when imported from a module verses dotsourced externally.Expected Behavior
Actual Behavior
Run
Output
Log
Environment
Logs
The text was updated successfully, but these errors were encountered: