gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error when using EXPORT UNQUALIFIED in an FFI def. module


From: Alice Osako
Subject: Error when using EXPORT UNQUALIFIED in an FFI def. module
Date: Tue, 2 Apr 2024 20:16:07 -0400
User-agent: Mozilla Thunderbird

When working on the FFI definition file for stdio for M2PP:

https://github.com/m2sf/m2pp/blob/master/src/posix/stdio.gm2.iso.def

the code as currently written includes an extensive EXPORT UNQUALIFIED statement for several of the constants, types, and procedures defined therein. According to Benjamin Kowarsch, this was originally done because - at the time the code was written - a gm2 FFI definition file did not allow unqualified imports without explicitly permitting it.

However, with the current build of gm2, this causes a peculiar error message, indicating a possible parsing error:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make -f Makefile bfsys

/home/schol-r-lea/opt/bin/gm2 -g -fiso -freport-bug -fdebug-function-line-numbers -Isrc/ -c src/imp/BasicFileSys.mod \
-o obj/BasicFileSys.o
src/stdio.def:20:1: warning: In definition module ‘stdio’: syntax warning, ‘END’ missing
   20 | FROM SYSTEM IMPORT
      | ^~~~
src/stdio.def:20:13: warning: syntax warning, ‘.’ missing
   20 | FROM SYSTEM IMPORT
      |             ^~~~~~
src/stdio.def:3:27: error: module name at beginning ‘stdio’ does not match the name at end ‘SYSTEM’
    3 | DEFINITION MODULE FOR "C" stdio; (* GNU Modula-2 ISO version *)
      |                           ^~~~~
src/stdio.def:20:1: error: syntax error, found ‘FROM’
   20 | FROM SYSTEM IMPORT
      | ^~~~
src/stdio.def:20:6: error: module name at end ‘SYSTEM’ does not match the name at beginning ‘stdio’
   20 | FROM SYSTEM IMPORT
      |      ^~~~~~
src/stdio.def:20:13: error: no scope active: syntax error, found ‘IMPORT’
   20 | FROM SYSTEM IMPORT
      |             ^~~~~~
src/stdio.def:146:11: error: compilation failed
  146 | END stdio.
      |           ^
make: *** [Makefile:93: bfsys] Error 1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It appears to cause the parser to treat the rest of the source file as garbage. When the EXPORT statement is deleted, compilation proceeds normally.

This appears to be a bug, though just what the correct behavior should be here isn't clear to me - either the statement is redundant, and should be removed anyway, or it is still necessary and should not raise an error, or else it is an error and should be flagged as such. I am assuming that the EXPORT is merely unneeded here; from what I was told, EXPORT should only normally be used in nested modules, anyway, but should still be syntactically valid in outer modules (just ignored).

Sorry to bring yet more things up here.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]