Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-checker allows modules to directly access state of other modules #662

Closed
peterwvj opened this issue Jan 24, 2018 · 4 comments
Closed
Labels
bug Incorrect behaviour of the tool Mergable A fix is available on a branch to merge for release
Milestone

Comments

@peterwvj
Copy link
Member

Description

Type-checker allows modules to directly access state of other modules.

Steps to Reproduce

Create a file A.vdmsl with the following content:

 module A

 exports all
 definitions

 state St of

 x : nat
 init s == s = mk_St(5)
 end

 end A

 module Entry

 imports from A all
 definitions

 operations

 Run : () ==> ?
 Run () == return A`x; -- ********* line 22 *********

 end Entry

Run java -jar Overture.jar -vdmsl A.vdmsl

Expected behavior: [What you expect to happen]

Expected error to be reported since you're not allowed to access state from another module like this.

Actual behavior: [What actually happens]

No error is reported.

Reproduces how often: [What percentage of the time does it reproduce?]

Every time.

Versions

Overture 2.5.6.

Additional Information

The issue is the same in VDMJ.

@peterwvj peterwvj added the bug Incorrect behaviour of the tool label Jan 24, 2018
@peterwvj peterwvj added this to the v2.6.0 milestone Jan 24, 2018
@nickbattle
Copy link
Contributor

This is correctly handled by VDMTools, saying that the A'x name is not found, since the imports all should not include it.

@nickbattle
Copy link
Contributor

This is because the "exports all" part of the type checker naively exports every definition from the module. It ought to strip out any state definitions before doing this. A VDMJ fix was easy, so Overture ought to be also.

@nickbattle
Copy link
Contributor

The correction now also includes a second error because the "import all" is for a module with no (effective) exports, now that the state definition is excluded:

Error 3190: Import all from module with no exports? in 'B' (test.vdm) at line 11:16
Error 3182: Name 'A`x' is not in scope in 'B' (test.vdm) at line 15:20

@nickbattle nickbattle added the Mergable A fix is available on a branch to merge for release label Jan 24, 2018
@peterwvj
Copy link
Member Author

Grreat, thanks! I'll include this fix in the release candidate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behaviour of the tool Mergable A fix is available on a branch to merge for release
Projects
None yet
Development

No branches or pull requests

2 participants