Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Sep 17, 2015
2 parents 6c1fb5a + 36d218a commit fc07851
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

package org.overturetool.vdmj.expressions;

import org.overturetool.vdmj.Release;
import org.overturetool.vdmj.Settings;
import org.overturetool.vdmj.definitions.BUSClassDefinition;
import org.overturetool.vdmj.definitions.CPUClassDefinition;
import org.overturetool.vdmj.definitions.ClassDefinition;
Expand Down Expand Up @@ -79,6 +81,11 @@ public Type typeCheck(Environment env, TypeList qualifiers, NameScope scope, Typ
report(3133, "Class name " + classname + " not in scope");
return new UnknownType(location);
}

if (Settings.release == Release.VDM_10 && env.isFunctional())
{
report(3348, "Cannot use 'new' in a functional context");
}

classdef = (ClassDefinition)cdef;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ public Type typeCheck(Environment env, TypeList qualifiers, NameScope scope, Typ

if (encl != null && encl.isPure())
{
report(3346, "Cannot use threadid in pure operations");
report(3346, "Cannot use 'threadid' in pure operations");
}

if (Settings.release == Release.VDM_10 && env.isFunctional())
{
report(3348, "Cannot use threadid in a functional context");
report(3348, "Cannot use 'threadid' in a functional context");
}

return checkConstraint(constraint, new NaturalType(location));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public Type typeCheck(Environment env, TypeList qualifiers, NameScope scope, Typ

if (encl != null && encl.isPure())
{
report(3346, "Cannot use time in pure operations");
report(3346, "Cannot use 'time' in pure operations");
}

if (Settings.release == Release.VDM_10 && env.isFunctional())
{
report(3348, "Cannot use time in a functional context");
report(3348, "Cannot use 'time' in a functional context");
}

return checkConstraint(constraint, new NaturalType(location));
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[3341, 3300, 3286, 3346, 3300, 3346, 3346, 3346, 3346, 3346, 3300, 3338, 3339, 3293, 3345, 3344, 3340, 3342, 3343, 3300, 3347, 3300, 3091, 3348, 3348, 5017]
[3341, 3300, 3286, 3346, 3300, 3346, 3346, 3346, 3346, 3346, 3300, 3338, 3339, 3293, 3345, 3344, 3340, 3342, 3343, 3300, 3347, 3300, 3091, 3348, 3348, 3348, 5017]
4 changes: 2 additions & 2 deletions FJ-VDMJ/src/test/resources/Overture/typecheck/puretest.vpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ values
v = 123;

operations
pure A: () ==> A
public pure A: () ==> A
A() ==
(
dcl z:nat := 0;
Expand Down Expand Up @@ -55,6 +55,6 @@ functions
f(a) == a.impop() + a.pre_impop(a) + a.op();

g:() -> nat
g() == time + threadid;
g() == time + threadid + new A().x;

end Test

0 comments on commit fc07851

Please sign in to comment.