Forum > General
procedure variables with advanced records
creaothceann:
This doesn't work:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program ProgramName; {$MODESWITCH AdvancedRecords} type T_ProcVar = procedure; T = record private procedure _Proc0; procedure _Proc1; procedure _Test(const p : T_ProcVar); public procedure Run; end; var tmp : T; procedure T._Proc0; begin end;procedure T._Proc1; begin end; procedure T._Test(const p : T_ProcVar);beginp;end; procedure T.Run;begin_Test(@_Proc0); // ← errorend; begintmp.Run;end.
--- Quote ---Compile Project, Target: AdvRec.exe: Exit code 1, Errors: 1, Hints: 1
AdvRec.lpr(34,14) Error: Incompatible type for arg no. 1: Got "<procedure variable type of procedure;Register>", expected "PROGRAMNAME.<procedure variable type of procedure;Register>"
AdvRec.lpr(26,13) Hint: Found declaration: _Test(const T_ProcVar);
--- End quote ---
Is this just a matter of syntax?
Changing "procedure;" to "procedure of object;" results in this message:
--- Quote ---AdvRec.lpr(34,14) Error: Incompatible type for arg no. 1: Got "<procedure variable type of procedure;Register>", expected "<procedure variable type of procedure of object;Register>"
--- End quote ---
Pascal:
Could be a bug!
--- Quote ---Got "<procedure variable type of procedure;Register>", expected "PROGRAMNAME.<procedure variable type of procedure;Register>"
--- End quote ---
Expected type has leading "PROGRAMNAME." which makes no sense. Except that the type is identical.
Bart:
Maybe https://www.freepascal.org/docs-html/ref/refse17.html help?
See the "is nested" part.
Bart
creaothceann:
--- Quote from: Bart on September 19, 2018, 12:06:35 pm ---Maybe https://www.freepascal.org/docs-html/ref/refse17.html help?
See the "is nested" part.
--- End quote ---
--- Code: ---{$MODESWITCH AdvancedRecords}
{$MODESWITCH NestedProcVars}
type
T_ProcVar = procedure is nested;
--- End code ---
--- Quote ---Compile Project, Target: AdvRec.exe: Exit code 1, Errors: 1, Hints: 1
AdvRec.lpr(38,14) Error: Incompatible type for arg no. 1: Got "<procedure variable type of procedure;Register>", expected "<procedure variable type of procedure is nested;Register>"
AdvRec.lpr(30,13) Hint: Found declaration: _Test(const T_ProcVar);
--- End quote ---
(and no, "of object is nested" isn't possible ::) )
bytebites:
Original code works in Delphi-mode and trunk-compiler
Navigation
[0] Message Index
[#] Next page