Mention that contains statement is missing if it does not precede module procedures

Open
#561 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
fortran
Domain
compilers

Research direction

Start by reproducing the diagnostic with the shown contains.f90 example and lfortran -c. Trace the parser or diagnostic entry point that reports the unexpected subroutine token; done means the message explains that a preceding CONTAINS statement is missing, with existing diagnostics still passing.

Written by the indexing model from the issue text.

Description

Original issue: https://gitlab.com/lfortran/lfortran/-/issues/729

As mentioned at Fortran Discourse, for a code with a missing contains statement such as

module m
implicit none
subroutine hello()
print*,"hi"
end subroutine hello
end module m 

for which lfortran -c says

syntax error: Token 'subroutine' is unexpected here
 --> contains.f90:3:1
  |
3 | subroutine hello()
  | ^
^^^^^^^^^

it would be even better to say

syntax error: Token 'subroutine' is unexpected here without a preceding CONTAINS statement

Dominant language
C++
Stars
1.2k
Forks
271
Avg merge
1d 2h
Merged PRs (30d)
173

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lfortran/lfortran

All issues in lfortran/lfortran

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.