Address @ of a function result string element causes Variable identifier expected error
Original Reporter info from Mantis: bunnylin @bunnylin
-
Reporter name: Kirinn
Original Reporter info from Mantis: bunnylin @bunnylin
- Reporter name: Kirinn
Description:
The below code compiles and runs on FPC 3.0.4, but produces a compilation error on 3.2.0 RC1: "Error: Variable identifier expected".
It seems like we can get the address of a function's result value directly, but we can't get the address of an index of the same without first saving it into a variable. If this change is intentional, a note should be added for User Changes on 3.2.0.
Steps to reproduce:
program test3;
function GetString : string; // <-- or UTF8string
begin
GetString := 'hello';
end;
var p : pointer;
s : string;
begin
s := GetString();
p := @s[1]; // <-- compiles ok
p := @GetString[1]; // <-- fails to compile in 3.2.0
end.
Mantis conversion info:
- Mantis ID: 37098
- OS: Windows
- OS Build: 7
- Build: 3.2.0RC1
- Platform: x86
- Version: 3.3.1