public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/114520] New: Incorrect ordering of import/export statements cause confusing error messages
@ 2024-03-28 15:46 gaius at gcc dot gnu.org
  2024-03-28 15:46 ` [Bug modula2/114520] " gaius at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-03-28 15:46 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-28 16:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 15:46 [Bug modula2/114520] New: Incorrect ordering of import/export statements cause confusing error messages gaius at gcc dot gnu.org
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

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).