FpDebug: fix constant char 'a' as array index. Amend Precedence for [n..m]

This commit is contained in:
Martin 2023-06-18 16:03:12 +02:00
parent a839afef06
commit aa389e7e47
2 changed files with 8 additions and 7 deletions

View File

@ -620,9 +620,9 @@ const
PRECEDENCE_BIT_SHIFT = 12; // << >> shr shr
PRECEDENCE_PLUS_MINUS = 13; // a + b
PRECEDENCE_OR = 13; // a OR b // XOR
PRECEDENCE_ARRAY_SLICE= 18; // array[5..9] // array slice
PRECEDENCE_IN = 19; // enum IN set // officially the same as PRECEDENCE_COMPARE
PRECEDENCE_COMPARE = 20; // a <> b // a=b
PRECEDENCE_ARRAY_SLICE= 30; // array[5..9] // array slice
type
@ -2595,7 +2595,9 @@ end;
function TFpPascalExpressionPartConstantText.DoGetResultValue: TFpValue;
begin
//s := GetText;
if Length(FValue) = 1 then
Result := TFpValueConstChar.Create(FValue[1])
else
Result := TFpValueConstString.Create(FValue);
{$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue'){$ENDIF};
end;
@ -2978,7 +2980,6 @@ var
end;
if not FValid then
exit;
// If Length(str) = 1 then // char
AddPart(TFpPascalExpressionPartConstantText);
TFpPascalExpressionPartConstantText(NewPart).FValue := str;
end;

View File

@ -3461,12 +3461,12 @@ begin
t.Add('Const-Expr: ansistring ', '''abc''''DE''', weAnsiStr('abcDE')).IgnKind;
t.Add('Const-Expr: ansistring ', '''abc''#32''DE''', weAnsiStr('abc DE')).IgnKind;
t.Add('Const-Expr: ansistring ', '#32''abc''', weAnsiStr(' abc')).IgnKind;
t.Add('Const-Expr: ansistring ', '#49', weAnsiStr('1')).IgnKind;
t.Add('Const-Expr: ansistring ', '#49#50', weAnsiStr('12')).IgnKind;
t.Add('Const-Expr: ansistring ', '#$30#$31', weAnsiStr('01')).IgnKind;
t.Add('Const-Expr: ansistring ', '#&61#&62', weAnsiStr('12')).IgnKind;
t.Add('Const-Expr: ansistring ', '#%110001', weAnsiStr('1')).IgnKind;
t.Add('Const-Expr: ansistring ', '#%00110001', weAnsiStr('1')).IgnKind;
t.Add('Const-Expr: ansistring ', '#49', weChar('1')).IgnKind;
t.Add('Const-Expr: ansistring ', '#%110001', weChar('1')).IgnKind;
t.Add('Const-Expr: ansistring ', '#%00110001', weChar('1')).IgnKind;
t.Add('Const-Expr: ansistring ', '''a', weAnsiStr('1')).IgnKind^.AddFlag(ehExpectError);
t.Add('Const-Expr: ansistring ', '''', weAnsiStr('1')).IgnKind^.AddFlag(ehExpectError);