Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Source/SimpleParser/SimpleParser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3648,6 +3648,16 @@ procedure TmwSimplePasPar.OrdinalType;
begin
ConstantExpression;
end;
{ An operator after the identifier means the bound is a constant
expression, not a type name: array[mlab + 1..mlog]. Reading it as a
type name consumes the identifier alone and leaves the caller at the
operator, where it can only report an error. These are the operators
SimpleExpression and Term accept. }
ptAnd, ptDiv, ptMinus, ptMod, ptOr, ptPlus, ptShl, ptShr, ptSlash,
ptStar, ptXor:
begin
ConstantExpression;
end;
else
begin
TypeID;
Expand Down
22 changes: 22 additions & 0 deletions Test/Snippets/arrayboundexpression.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
unit arrayboundexpression;

interface

const
mlab = 4;
mlog = 12;

type
{ An array bound is a constant EXPRESSION, not just a constant or a type name.
OrdinalType decided on one token of lookahead and read `mlab` as a type name,
so the whole unit failed to parse at the `+`. }
TRanges = record
iu: array[mlab + 1..mlog] of Integer;
du: array[mlab * 2..mlog - 1, 0..mlab shl 1] of Byte;
end;

TSetOfExpression = set of mlab + 1..mlog;

implementation

end.