public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gaius at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug modula2/114520] New: Incorrect ordering of import/export statements cause confusing error messages
Date: Thu, 28 Mar 2024 15:46:41 +0000	[thread overview]
Message-ID: <bug-114520-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114520

            Bug ID: 114520
           Summary: Incorrect ordering of import/export statements cause
                    confusing error messages
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

As reported on the gm2 mailing list:

$ cat localmodule2.mod
MODULE localmodule2 ;

FROM libc IMPORT printf ;

PROCEDURE mult2 (n: CARDINAL) : CARDINAL ;
BEGIN
   RETURN 2*n
END mult2 ;

MODULE local ;

  EXPORT mysqr ;
  IMPORT mult2 ;

  PROCEDURE mysqr (n: CARDINAL) : CARDINAL ;
  BEGIN
     RETURN mult2 (n) * mult2 (n)
  END mysqr ;

END local ;

VAR
   d: CARDINAL ;
BEGIN
   d := mysqr (3) ;
   printf ("sqr (3 * 2) = %d\n", d)
END localmodule2.


$ gm2 localmodule2.mod 
localmodule2.mod:13:10: warning: In inner module ‘local’: syntax warning, ‘END’
missing 
   13 |   IMPORT mult2 ;
      |          ^~~~~
localmodule2.mod:20:11: warning: In program module ‘localmodule2’: syntax
warning, ‘.’ missing 
   20 | END local ;
      |           ^
localmodule2.mod:1:8: error: module name at beginning ‘localmodule2’ does not
match the name at end ‘local’
    1 | MODULE localmodule2 ;
      |        ^~~~~~~~~~~~
localmodule2.mod:10:8: error: In inner module ‘local’: module name at beginning
‘local’ does not match the name at end ‘mult2’
   10 | MODULE local ;
      |        ^~~~~
localmodule2.mod:13:3: error: syntax error, found ‘IMPORT’
   13 |   IMPORT mult2 ;
      |   ^~~~~~
localmodule2.mod:13:10: error: module name at end ‘mult2’ does not match the
name at beginning ‘local’
   13 |   IMPORT mult2 ;
      |          ^~~~~
localmodule2.mod:20:5: error: In program module ‘localmodule2’: module name at
end ‘local’ does not match the name at beginning ‘localmodule2’
   20 | END local ;
      |     ^~~~~
localmodule2.mod:20:11: error: syntax error, found ‘;’
   20 | END local ;
      |           ^
localmodule2.mod:28:1: error: no scope active: compilation failed


The user level fix is to switch the IMPORT and EXPORT statement lines.
However the compiler should generate a more meaningful error message.

             reply	other threads:[~2024-03-28 15:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28 15:46 gaius at gcc dot gnu.org [this message]
2024-03-28 15:46 ` [Bug modula2/114520] " gaius at gcc dot gnu.org
2024-03-28 16:25 ` gaius at gcc dot gnu.org
2024-03-28 16:29 ` gaius at gcc dot gnu.org
2024-03-28 16:50 ` cvs-commit at gcc dot gnu.org
2024-03-28 16:52 ` gaius at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114520-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).