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

Confusing parse errors for bad array specs #625

Open
tskeith opened this issue Aug 5, 2019 · 1 comment
Open

Confusing parse errors for bad array specs #625

tskeith opened this issue Aug 5, 2019 · 1 comment
Assignees

Comments

@tskeith
Copy link
Collaborator

tskeith commented Aug 5, 2019

Test program:

subroutine s(x)
  real :: x(10,:)
end

Compiler output:

a.f90:6:8: error: expected '('
    real :: x(10,:)
         ^
a.f90:6:3: in the context: statement function definition
    real :: x(10,:)
    ^
a.f90:6:3: in the context: declaration construct
a.f90:6:3: in the context: specification part
a.f90:5:1: in the context: SUBROUTINE subprogram
  subroutine s(x)
  ^

In this case the user has combined valid shape-specs (10 and :) in a way that makes an invalid array-spec. But the error messages aren't very helpful to figure that out.

Here are some other examples that get a similar error message:

real :: x(*,10)
real :: x(10,..)
real :: x(:,*)

One fix would be for the parser to accept any sequence of shape-specs and then leave it to semantics to report bad combinations. We already have to detect valid array-specs that are used in the wrong context.

@klausler
Copy link
Collaborator

klausler commented Aug 5, 2019

Another approach to a fix would be to perform custom error recovery on array-specs, and just accept any list of token sequences with properly nested parentheses.

@sscalpone sscalpone added the enhancement New feature or request label Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants