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

Indenting in the Outline pane is incorrect if a macro has a statement without a semicolon immediately prior to the %MEND statement #1324

Open
david-mcnamara opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@david-mcnamara
Copy link

If a SAS code file contains macros, and any of those macros contain code that ends without a semicolon immediately prior to the macro's %MEND statement, then the macros that follow will be incorrectly indented as if the macros are nested.

Here is some nonsense example code that demonstrates the issue:

%macro one(param);
    abc = &param;
%mend one;
%macro two(param);
    abc = &param
%mend two;
%macro three(param);
    %if %length(&param) = 0 %then %do;
        %return;
    %end;
    %substr(&param, 2)
%mend three;
%macro four;
%mend;
%macro five(param);
    &param
%mend;
%macro six(param);
    &param;
%mend;
%macro seven(param);
    &param;
%mend;

If this code is opened in VS Code, the Outline pane looks like this, even though none of the macros are actually nested:
image

Looking at the colored highlighting within the editor, we can see that the %mend statements on lines 6, 12, and 17 are shown in pink, whereas all the others are in blue.
image

The ones highlighted in pink, are ones where the line immediately preceding the %mend statement are not terminated by a semicolon. (It should be noted that it is valid for lines not to be terminated by semicolons.)

It would appear that the tokenizing/parsing of the code is expecting a semicolon to precede the %mend in order to determine the end of a macro definition.

@david-mcnamara david-mcnamara added the bug Something isn't working label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant