fix broken try catch parse

This commit is contained in:
2023-03-28 21:20:18 +01:00
parent 1c35ce6856
commit c5c5fef4bc

View File

@@ -28,6 +28,9 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat
return TryCatch{}, false, err, i return TryCatch{}, false, err, i
} }
totalIndex += i totalIndex += i
if index+totalIndex >= len(codelines) {
return TryCatch{}, false, ArErr{"Syntax Error", "expected catch statement", code.line, code.path, code.realcode, true}, i
}
catchtrimmed := strings.TrimSpace(codelines[index+totalIndex].code) catchtrimmed := strings.TrimSpace(codelines[index+totalIndex].code)
if !catchCompiled.MatchString(catchtrimmed) { if !catchCompiled.MatchString(catchtrimmed) {
return TryCatch{}, false, ArErr{"Syntax Error", "invalid syntax", code.line, code.path, code.realcode, true}, i return TryCatch{}, false, ArErr{"Syntax Error", "invalid syntax", code.line, code.path, code.realcode, true}, i
@@ -36,7 +39,6 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat
catchbracketSplit := strings.SplitN(catchtrimmed, ")", 2) catchbracketSplit := strings.SplitN(catchtrimmed, ")", 2)
errorName := strings.TrimSpace(strings.TrimSpace(catchbracketSplit[0])[1:]) errorName := strings.TrimSpace(strings.TrimSpace(catchbracketSplit[0])[1:])
errcode := catchbracketSplit[1] errcode := catchbracketSplit[1]
catchparsed, worked, err, i := translateVal(UNPARSEcode{errcode, code.realcode, code.line, code.path}, index+totalIndex, codelines, 1) catchparsed, worked, err, i := translateVal(UNPARSEcode{errcode, code.realcode, code.line, code.path}, index+totalIndex, codelines, 1)
if !worked { if !worked {
return TryCatch{}, false, err, i return TryCatch{}, false, err, i