View Issue Details

IDProjectCategoryView StatusLast Update
0035909FPCCompilerpublic2020-03-06 11:51
ReporterOndrej PokornyAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0035909: IS operator precendence is wrong
DescriptionAccording to
https://www.freepascal.org/docs-html/ref/refch12.html and
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Expressions_(Delphi)#Operator_Precedence
the is operator has the lowest precedence.

But in reality it is not so. The compiler evaluates the IS operator before OR.
Steps To Reproduceprogram IS_Precedence;
uses
  Classes;
var
  O1, O2: TObject;
begin
  O1 := TComponent.Create(nil);
  O2 := TObject.Create;
  Writeln(O1 is TComponent or O2 is TComponent); // <<< should not compile because OR has precedence before IS
end.
Additional InformationDelphi (correctly) fails to compile the program in "Steps To Reproduce".
TagsNo tags attached.
Fixed in Revision44266
FPCOldBugId
FPCTarget-
Attached Files

Activities

Kai Burghardt

2019-07-30 17:28

reporter   ~0117510

An expression “<class> or <object>” doesn’t make sense. The compiler correctly assumes it must read “<object> is <class>”. Maybe this heuristic should be documented.

Ondrej Pokorny

2020-03-06 11:51

developer   ~0121411

Thank you very much!

Issue History

Date Modified Username Field Change
2019-07-30 08:02 Ondrej Pokorny New Issue
2019-07-30 17:28 Kai Burghardt Note Added: 0117510
2020-03-06 11:20 Florian Assigned To => Florian
2020-03-06 11:20 Florian Status new => resolved
2020-03-06 11:20 Florian Resolution open => fixed
2020-03-06 11:20 Florian Fixed in Version => 3.3.1
2020-03-06 11:20 Florian Fixed in Revision => 44266
2020-03-06 11:20 Florian FPCTarget => -
2020-03-06 11:51 Ondrej Pokorny Status resolved => closed
2020-03-06 11:51 Ondrej Pokorny Note Added: 0121411