View Issue Details

IDProjectCategoryView StatusLast Update
0035834FPCDocumentationpublic2019-07-15 12:53
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionProduct Build 
Target VersionFixed in Version3.3.1 
Summary0035834: It is not clear enough that Boolean operators have equal weight (operator precedence)
DescriptionBoolean operators have equal weight and evaluation is left to right.
In the section about operator precedence this is not clear, even a bit confusing.
https://www.freepascal.org/docs-html/ref/refch12.html#x139-16100012
TagsNo tags attached.
Fixed in Revision1633
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Thaddy de Koning

2019-07-12 09:46

reporter   ~0117210

See reporting reason here https://forum.lazarus.freepascal.org/index.php/topic,46054.msg326889.html#msg326889

wp

2019-07-15 12:38

reporter   ~0117264

> Boolean operators have equal weight and evaluation is left to right.

This is wrong. AND has a higher priority than OR.

Example:
  program Project1;
  begin
    WriteLn(true or true and false);
    ReadLn;
  end.

Output:
  TRUE

If AND and OR had the same weight, the output would be FALSE: from left to right: true or true = true, true and false = false.
If AND has a higher priority (as documented), the AND expression is evalueded first which results in false (true and false = false). The following OR with the first parameter (true) results in true.

Michael Van Canneyt

2019-07-15 12:53

administrator   ~0117265

I changed the description to be more clear and added Werner's example.

Issue History

Date Modified Username Field Change
2019-07-12 09:41 Thaddy de Koning New Issue
2019-07-12 09:41 Thaddy de Koning Status new => assigned
2019-07-12 09:41 Thaddy de Koning Assigned To => Michael Van Canneyt
2019-07-12 09:46 Thaddy de Koning Note Added: 0117210
2019-07-15 12:38 wp Note Added: 0117264
2019-07-15 12:53 Michael Van Canneyt Status assigned => resolved
2019-07-15 12:53 Michael Van Canneyt Resolution open => fixed
2019-07-15 12:53 Michael Van Canneyt Fixed in Version => 3.3.1
2019-07-15 12:53 Michael Van Canneyt Fixed in Revision => 1633
2019-07-15 12:53 Michael Van Canneyt FPCTarget => 3.2.0
2019-07-15 12:53 Michael Van Canneyt Note Added: 0117265