gsdlab / clafer

Clafer is a lightweight modeling language
http://clafer.org
MIT License
45 stars 13 forks source link

Fixed i226 #25

Closed Luke-Michael-Brown closed 11 years ago

Luke-Michael-Brown commented 11 years ago

see http://gsd.uwaterloo.ca:8888/question/948/unary-minus-generated-incorrectly-for-alloy42

Simple change of (-exp) to (exp*(-1))

mantkiew commented 11 years ago

Tested and works well. Here's a summary of outputs for old clafer and the one in i226:

// Alloy 4.1 (old)
fact { (c1_x.@ref) = ((-(1.add[2])).div[3]) }

// Alloy 4.1 (new)
fact { (c1_x.@ref) = (((1.add[2]).mul[-1]).div[3]) }

// Alloy 4.2 (old)
fact { (c1_x.@ref) = ((.minus[](1.plus[2])).div[3]) }

// Alloy 4.2 (new)
fact { (c1_x.@ref) = (((1.plus[2]).mul[-1]).div[3]) }

This can be merged.