Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

declare expressions break the server #1177

Open
johnperry-math opened this issue Jan 1, 2024 · 1 comment
Open

declare expressions break the server #1177

johnperry-math opened this issue Jan 1, 2024 · 1 comment
Assignees
Labels

Comments

@johnperry-math
Copy link

Declare expressions were introduced in Ada 2022. For example:

function Can_Move (Here, From : Location_Record) return Boolean is
(declare Current : constant Pipe := Map (From.Row, From.Col); begin (
  case Map (Here.Row, Here.Col) is
    when Vertical =>      -- |
      (From.Col = Here.Col and then From.Row - Here.Row = 1
       and then Current /= Horizontal
       and then Current /= ES_Or_NW
       and then Current /= WS_Or_NE)
      or else
      (From.Col = Here.Col and then From.Row - Here.Row = -1
       and then Current /= Horizontal
       and then Current /= SW_Or_EN
       and then Current /= SE_Or_WN),
--  ...

I used this on day 10 of Advent of Code 2023, and while it compiled and ran fine, the VSCode Ada plugin replied

[Error - 4:50:51 PM] Request textDocument/formatting failed.
  Message: day10.adb:1:1: Error formatting node (CompilationUnit). Keeping the initial input selection unchanged
null template: <DeclExpr day10.adb:148:7-208:56>
  Code: -32603

This would seem to be a bug. I realize Ada 2022 support is a work in progress, but if user feedback helps prioritize things... :-)

In fact, I would be willing to contribute to this fix, and will try taking a look at it. Since I've never looked at this before, any suggestions on where to start would be appreciated.

@setton
Copy link
Member

setton commented Jan 2, 2024

Hi @johnperry-math - thank you for the heads-up!

The fix would be adding support for declare expressions above this line https://github.com/AdaCore/libadalang-tools/blob/8702a8f4240fe4cdaaad5c0fdeeb1a27816280fd/src/pp-actions.adb#L4011 - but I wouldn't try to fix this, since we're in the process of changing completely the formatting engine. We'll make sure to support the declare expressions in the new engine.

All the best,

Nicolas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants