View Issue Details

IDProjectCategoryView StatusLast Update
0036090FPCDocumentationpublic2019-09-19 23:34
ReporterKirinnAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.0.4Product Build 
Target VersionFixed in Version3.3.1 
Summary0036090: Clarify documentation on case-else statement
DescriptionReference guide, the case statement (13.2.2)

The case else part works implicitly as a block, accepting multiple command statements, which is by design. The documentation should be clearer on this.

It says: "The case statements can be compound statements (i.e. a Begin..End block)." To this could be added: "The else part can contain multiple statements even without a Begin..End block."

Additionally, under the section "The following are valid case statements", one of the examples should include a two-line else statement to show it is possible.
TagsNo tags attached.
Fixed in Revision1654
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

Marco van de Voort

2019-09-19 22:49

manager   ~0118123

The else part CAN'T contain multiple statements without begin..end. A counterexample would be necessary.

Note that if you need multiple else statements, you are probably of the track. Search for dangling else.

Michael Van Canneyt

2019-09-19 23:23

administrator   ~0118125

@marco, of course the else part can contain multiple statements:

begin
  case random(10) of
    1 : writeln(1);
  else
    Writeln('a');
    Writeln('b');
    Writeln('ahah');
    end;
 end.

compiles and runs fine. You can't have multiple else clauses of course.

Michael Van Canneyt

2019-09-19 23:34

administrator   ~0118126

Well, the syntax diagram clearly mentions 'statement list' in the else clause. But I added an example, and made it more explicit.

Issue History

Date Modified Username Field Change
2019-09-19 22:04 Kirinn New Issue
2019-09-19 22:04 Kirinn Status new => assigned
2019-09-19 22:04 Kirinn Assigned To => Michael Van Canneyt
2019-09-19 22:49 Marco van de Voort Status assigned => feedback
2019-09-19 22:49 Marco van de Voort FPCTarget => -
2019-09-19 22:49 Marco van de Voort Note Added: 0118123
2019-09-19 23:23 Michael Van Canneyt Note Added: 0118125
2019-09-19 23:34 Michael Van Canneyt Status feedback => resolved
2019-09-19 23:34 Michael Van Canneyt Resolution open => fixed
2019-09-19 23:34 Michael Van Canneyt Fixed in Version => 3.3.1
2019-09-19 23:34 Michael Van Canneyt Fixed in Revision => 1654
2019-09-19 23:34 Michael Van Canneyt FPCTarget - => 3.2.0
2019-09-19 23:34 Michael Van Canneyt Note Added: 0118126