Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Act/Lex.x
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ tokens :-
-- symbols
":=" { mk ASSIGN }
"=>" { mk ARROW }
"<-" { mk LARROW }
"|->" { mk POINTSTO }
"==" { mk EQEQ }
"=/=" { mk NEQ }
Expand Down Expand Up @@ -186,6 +187,8 @@ data LEX =
-- symbols
| ASSIGN
| ARROW
| LARROW
| POINTSTO
| EQEQ
| NEQ
| GE
Expand Down
3 changes: 2 additions & 1 deletion src/Act/Parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import Act.Error
-- symbols
':=' { L ASSIGN _ }
'=>' { L ARROW _ }
'<-' { L LARROW _ }
'|->' { L POINTSTO _ }
'==' { L EQEQ _ }
'=/=' { L NEQ _ }
Expand Down Expand Up @@ -209,7 +210,7 @@ Storage : 'storage' nonempty(Store) { $2 }
Precondition : 'iff' nonempty(Expr) { Iff (posn $1) $2 }
| 'iff in range' AbiType nonempty(Expr) { IffIn (posn $1) $2 $3 }

Store : Entry '=>' Expr { Rewrite $1 $3 }
Store : Entry '<-' Expr { Rewrite $1 $3 }

Entry : id { EVar (posn $1) (name $1) }
| Entry '[' Expr ']' list(Index) { EMapping (posn $2) $1 ($3:$5) }
Expand Down
2 changes: 1 addition & 1 deletion src/Act/Print.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ prettyLocation :: StorageLocation t -> String
prettyLocation (Loc _ item) = prettyItem item

prettyUpdate :: StorageUpdate t -> String
prettyUpdate (Update _ item e) = prettyItem item <> " => " <> prettyExp e
prettyUpdate (Update _ item e) = prettyItem item <> " <- " <> prettyExp e

prettyEnv :: EthEnv -> String
prettyEnv e = case e of
Expand Down
14 changes: 14 additions & 0 deletions tests/postconditions/pass/assignment_poststate.act
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
constructor of C
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is added in the postcodnitions directory, so it should have an ensures block.

interface constructor(uint x0)

creates

uint x := x0

behaviour f of C
interface f()

storage
x <- post(x)

returns post(x)
13 changes: 5 additions & 8 deletions tests/postconditions/pass/assignment_prestate.act
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
constructor of C
interface constructor(uint24 _x)
interface constructor(uint x0)

creates

uint24 x := _x
uint x := x0

behaviour f of C
interface f(uint24 y)
interface f()

storage
x <- pre(x)

x => x + y

ensures
Copy link
Collaborator

@zoep zoep Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test for postconditions, so the ensures block should not be removed.


post(x) == pre(x) + y
returns pre(x)
4 changes: 2 additions & 2 deletions tests/postconditions/pass/increase.act
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ interface increase(uint24 new_x)

case new_x > x:
storage
x => new_x
x <- new_x

returns post(x) - pre(x)

case new_x <= x:
storage
x => x + new_x
x <- x + new_x

returns post(x) - pre(x)

Expand Down
Loading