ada-mode-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ada-mode-users] Function expression returning an aggregate that is not


From: Ludovic Brenta
Subject: [Ada-mode-users] Function expression returning an aggregate that is not enclosed in an expression
Date: Wed, 16 Nov 2016 14:13:24 +0200
User-agent: Roundcube Webmail/0.5.3

Hello, the following legal sources cause a parse error:

procedure P is
  type T is record
    Component : Boolean;
  end record;
  function F return T is (Component => True); -- line 5
begin
  null;
end P;

I know that this is illegal in Ada 2012 but it became legal with
AI12-0157[1] (i.e. binding interpretation) and GNAT compiles it.
The ada-mode parser currently fails with:

p.adb:5:38: syntax error in grammar state 884; unexpected =>, expecting one of (default RIGHT_PAREN)

This requires the programmer to add extra parens around the aggregate:

  function F return T is ((Component => True));

or not use an expression function:

  function F return T is begin return (Component => True); end F;

[1] http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai12s/ai12-0157-1.txt?rev=1.6&raw=N

--
Ludovic Brenta.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]