【问题标题】:FreePascal syntax error "invalid qualifier", but it compiles in Delphi 7FreePascal 语法错误 \"invalid qualifier\",但它在 Delphi 7 中编译
【发布时间】:2023-01-22 23:47:19
【问题描述】:

下面的代码在 Delphi 7 中编译,但在 FPC 中出错。是否有任何模式开关可以使其编译?

procedure Test;
type
  TArray = array of Integer;
  TArrayFunc = function: TArray;
var
 a: TArray;
 f: TArrayFunc;
 i: integer;
begin
 i := f[0]; //* FPC: "Error: Illegal qualifier"
 i := f()[0]; //* Compiles in D7 and FPC
end;

【问题讨论】:

  • 只需使用f()[0]
  • 你用{$MODE Delphi}把FPC放到Delphi mode有没有同样的问题?
  • 是的。今天我试了所有 {$mode} 和 {$modeswith} 指令,但它无法编译,所以我认为 FPC-3.2.2 不支持这种语法。谢谢你。

标签: delphi-7 freepascal


【解决方案1】:

这是 FPC 3.2.2 中的错误。我刚刚在 FPC 3.3.1 中修复了它:https://gitlab.com/freepascal.org/fpc/source/-/commit/ec28b7586c4b74823555f196772743fe9bfa3dde

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多