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 a zero literal index for sequences #726

Closed
nickbattle opened this issue Jun 5, 2020 · 1 comment
Closed

Type checker allows a zero literal index for sequences #726

nickbattle opened this issue Jun 5, 2020 · 1 comment
Labels
bug Incorrect behaviour of the tool language Issues in parser, TC, interpreter, POG or CG Mergable A fix is available on a branch to merge for release
Milestone

Comments

@nickbattle
Copy link
Contributor

VDM uses 1-relative sequence indexes, but it is a common mistake for people to write seq(0) when they mean seq(1). This should give an error in the type checker; currently the type checking is clean and it fails at runtime. So for example:

values
	S = [1,2,3,4];
	T = S(0);

That produces no TC errors, but at runtime (initialization here) you get "Error 4058: Value 0 is not a nat1".

@nickbattle nickbattle added bug Incorrect behaviour of the tool language Issues in parser, TC, interpreter, POG or CG labels Jun 5, 2020
@nickbattle
Copy link
Contributor Author

Now fixed in ncb/development:

Parsed 1 module in 0.103 secs. No syntax errors
Error 3056: Sequence application argument must > 0 in 'DEFAULT' (test.vdm) at line 3:9
Type checked 1 module in 0.146 secs. Found 1 type error
Bye

@nickbattle nickbattle added the Mergable A fix is available on a branch to merge for release label Jun 5, 2020
@idhugoid idhugoid added this to the v3.0.0 milestone Aug 28, 2020
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 language Issues in parser, TC, interpreter, POG or CG Mergable A fix is available on a branch to merge for release
Projects
None yet
Development

No branches or pull requests

2 participants