Skip to content

Commit

Permalink
Check for invariant types when converting function values, fixes #761
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbattle committed Oct 31, 2020
1 parent 1e8e9a6 commit b42facd
Showing 1 changed file with 11 additions and 2 deletions.
Expand Up @@ -50,6 +50,7 @@
import org.overture.ast.patterns.APatternTypePair;
import org.overture.ast.patterns.PPattern;
import org.overture.ast.types.AFunctionType;
import org.overture.ast.types.ANamedInvariantType;
import org.overture.ast.types.PType;
import org.overture.ast.util.Utils;
import org.overture.config.Settings;
Expand Down Expand Up @@ -804,15 +805,23 @@ protected Value convertValueTo(PType to, Context ctxt, Set<PType> done)
List<PType> domain = tc.narrowest(type.getParameters(), restrictedType.getParameters());
PType range = tc.narrowest(type.getResult(), restrictedType.getResult());
AFunctionType newType = AstFactory.newAFunctionType(location, true, domain, range);

// Create a new function with the narrowest domain/range.
FunctionValue restricted = new FunctionValue(location, name,
newType, paramPatternList, body, precondition, postcondition,
freeVariables, checkInvariants, curriedArgs, measureName,
measureValues, result);

restricted.typeValues = typeValues;
return restricted;

if (to instanceof ANamedInvariantType)
{
return new InvariantValue((ANamedInvariantType)to, restricted, ctxt);
}
else
{
return restricted;
}
}
}
}
Expand Down

0 comments on commit b42facd

Please sign in to comment.