[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with import/export in local modules
From: |
Gaius Mulley |
Subject: |
Re: Problem with import/export in local modules |
Date: |
Thu, 28 Mar 2024 11:14:28 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
john o goyo <jog37@riddermarkfarm.ca> writes:
> Greetings, Gaius.
>
> The following module fails compilation.
>
>
> MODULE Test;
>
> PROCEDURE Double(n :CARDINAL) :CARDINAL;
> BEGIN
> RETURN 2*n
> END Double;
>
> MODULE Inside;
>
> EXPORT Quadruple;
> IMPORT Double;
>
> PROCEDURE Quadruple(k :CARDINAL) :CARDINAL;
> BEGIN
> RETURN Double(k) * Double(k)
> END Quadruple;
>
> END Inside;
>
> VAR
> d :CARDINAL;
> BEGIN
> d := Quadruple(3)
> END Test.
>
>
> This is a minimal version of a much larger legacy module. I believe
> the above to be valid.
>
> The following is the compilation.
>
> => gm2-git -c Test.mod
> Test.mod:12:12: warning: In inner module ": syntax warning, " missing
> 12 | IMPORT Double;
> | ^~~~~~
> Test.mod:19:11: warning: In program module ": syntax warning, " missing
> 19 | END Inside;
> | ^
> Test.mod:1:8: error: module name at beginning " does not match the
> name at end "
> 1 | MODULE Test;
> | ^~~~
> Test.mod:9:8: error: In inner module â: module name at beginning "
> does not match the name at end "
> 9 | MODULE Inside;
> | ^~~~~~
> Test.mod:12:5: error: syntax error, found "
> 12 | IMPORT Double;
> | ^~~~~~
> Test.mod:12:12: error: module name at end " does not match the name at
> beginning "
> 12 | IMPORT Double;
> | ^~~~~~
> Test.mod:19:5: error: In program module ": module name at end " does
> not match the name at beginning "
> 19 | END Inside;
> | ^~~~~~
> Test.mod:19:11: error: syntax error, found "
> 19 | END Inside;
> | ^
> Test.mod:29:1: error: no scope active: compilation failed
>
> (I am also mystified by the quotation marks.)
Hi John,
ah yes - the error messages are misleading. The bug is that the
EXPORT/IMPORT statements are in the wrong order and the error recovery
has become confused!
IMPORT Double;
EXPORT Quadruple;
and it compiles,
regards,
Gaius