View Issue Details

IDProjectCategoryView StatusLast Update
0038269FPCDocumentationpublic2020-12-29 17:23
ReporterJoubert Nel Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.2.0 
Fixed in Version3.3.1 
Summary0038269: ^C prefixed to string constants causes fpdoc (and fcl-passrc) to fail
DescriptionSome source files contain string constants where the value is prefixed with the literal text ^C, causing fpdoc and fcl-passrc to fail.

When these declarations are encountered:
a) fpdoc skips over the rest of the file
b) my use of fcl-passrc triggers an access violation (I'm still trying to track down how I can safely handle this case)
c) fpc compiles without error and the resulting code runs fine.

For example, fpcsrc/3.2.0/packages/ide/fptools.pas contains:
     const msg_errorparsingparametersatpos = ^C'Error parsing parameters line at line position %d.';

Also asked in the forums & got some replies including:
a) why do some of the source files contain this pattern?
b) can fcl-passrc / fpdoc be improved to handle this case (if this syntax is valid)

https://forum.lazarus.freepascal.org/index.php/topic,52678.0.html
Steps To ReproduceDeclaration:
     const msg_errorparsingparametersatpos = ^C'Error parsing parameters line at line position %d.';
Additional InformationAttached is a minimal example:

a) console app that uses two units:
      - ParseIssue.pas (contains constant string with ^C prefix)
      - ParseNonIssue.pas

b) directory containing fpdoc output by running "fpdoc --package-name=caretC --input-dir=."

TagsNo tags attached.
Fixed in Revision47889
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Joubert Nel

2020-12-28 17:34

reporter  

caretC.zip (18,110 bytes)

Michael Van Canneyt

2020-12-29 11:44

administrator   ~0127892

Fixed.
But the use of ^C is discouraged.
It's difficult to decide whether ^C means pointer to identifier C or marks the start of a string.

Better replace it with 0000003.

Sven Barth

2020-12-29 17:03

manager   ~0127901

It's not difficult: ^IDENTIFIER can only be used as a type alias (meaning after an = inside a type section) or for an anonymous type (meaning after a : in a variable or field section). Both are cases where string constants can't be used.
In FPC that's handled completely by the scanner (see scanner.pas, around line 5213; look for c='^').

Michael Van Canneyt

2020-12-29 17:23

administrator   ~0127907

Sven, I know all that.

Without context you cannot know whether ^C is a pointer or the start of a string.

I am of the opinon that a scanner should not have context.
and the ^C introduces context in the scanner, which is why I think it should be discouraged.

(for the same reason I think the generics syntax is such a horrible beast)

Issue History

Date Modified Username Field Change
2020-12-28 17:34 Joubert Nel New Issue
2020-12-28 17:34 Joubert Nel Status new => assigned
2020-12-28 17:34 Joubert Nel Assigned To => Michael Van Canneyt
2020-12-28 17:34 Joubert Nel File Added: caretC.zip
2020-12-29 11:44 Michael Van Canneyt Status assigned => resolved
2020-12-29 11:44 Michael Van Canneyt Resolution open => fixed
2020-12-29 11:44 Michael Van Canneyt Fixed in Version => 3.3.1
2020-12-29 11:44 Michael Van Canneyt Fixed in Revision => 47889
2020-12-29 11:44 Michael Van Canneyt FPCTarget => 3.2.2
2020-12-29 11:44 Michael Van Canneyt Note Added: 0127892
2020-12-29 17:03 Sven Barth Note Added: 0127901
2020-12-29 17:23 Michael Van Canneyt Note Added: 0127907