Skip to content

Broken handling of conditional expressions #3

@paralogismos

Description

@paralogismos

It seems that old-ada-mode is broken when handling case expressions and if expressions. Consider the two code examples below:

with Ada.Text_IO; use Ada.Text_IO;

procedure Case_Expr is
   type Pet is (Dog, Cat, Goldfish);
   My_Pet : Pet := Dog;
begin
   Put_Line(
     (case My_Pet is
        when Dog => "Doggie",
        when Cat => "Kitty",
        when Goldfish => "Fishy"));
end Case_Expr;
with Ada.Text_IO; use Ada.Text_IO;

procedure If_Expr is
   type Pet is (Dog, Cat, Goldfish);
   My_Pet : Pet := Dog;
begin
   Put_Line(
     (if My_Pet = Dog then "Doggie"
     elsif My_Pet = Cat then "Kitty"
     else "Goldfish"));
end If_Expr;

These are legal Ada programs which compile and run, but old-ada-mode complains about "No matching proc/func/task/declare/package/protected." When the conditional expression occurs in a loop old-ada-mode complains of the end loop that "Matching start is not 'loop'."

Note that old-ada-mode can be satisfied by the inclusion of a "matching" end case or end if, but then the code is no longer legal Ada code and will not compile.

This issue does not prevent one from writing correct code, but it does cause much unpleasantness and havoc with formatting and ada-mode warnings below any occurrences of conditional expressions in source code.

Conditional expressions were an addition to Ada 2012, so I suspect that old-ada-mode just predates these newer language features; still, this is an annoying gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions