Skip to content

Compiler syntax error on parsing simple generics code

Summary

System Information

  • Operating system: any
  • Processor architecture: any
  • Compiler version: main branch
  • Device: linux 64-bit (x86_64)

Steps to reproduce

Unzip attached project. It contains 3 units: s, c and b.

Attempt to compile unit s, it will fail with a syntax error:

> fpc s.pas 
s.pas(40,52) Fatal: Syntax error, ")" expected but "," found
Fatal: Compilation aborted

The line that fails to compile is really simple:

 B:=FindStyleResource<TBrushObject>( 'foreground' , BrushObject );

a seemingly simple function specialization.

(Perhaps needless to say, but Delphi compiles this.)

Example Project

See zip genbug.zip

What is the current bug behavior?

Compiler ends with syntax error.

What is the expected (correct) behavior?

The compiler compiles the code...

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information