Skip to content

Type Mismatch error when passing a variant to string type parameter #277

@ccy

Description

@ccy

When compile this script, I encounter Type Mismatch error:

var V: Variant;
begin
  V := ''Test''; 
  UpperCase(V); 
end.

If change V to string, it compile without error:

var V: string;
begin
  V := ''Test''; 
  UpperCase(V); 
end.

The issue happens to changes of uPSCompiler.pas in commit 1cabc17

        else if Tmp.ExpectedType = FAnyString then begin
          Tmp.ExpectedType := GetTypeNo(BlockInfo, tmp.Val);
          if not IsStringOrCharType(Tmp.ExpectedType.BaseType) then
          begin
            MakeError('', ecTypeMismatch, '');
            Cleanup;
            exit;
          end;
        end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions