Skip to content

Commit

Permalink
inline authorized-by parameters, fixes #1294 (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoeldner authored Aug 31, 2023
1 parent 2a6e8ca commit 8a65a50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src-tool/Pact/Analyze/Parse/Prop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,11 @@ inferPreProp preProp = case preProp of
(Some SBool . PropSpecific) ... RowExists tn'
<$> checkPreProp SStr rk
<*> parseBeforeAfter beforeAfter
PreApp s [PreStringLit rn] | s == SAuthorizedBy ->
pure $ Some SBool (PropSpecific (GuardPassed (RegistryName rn)))
PreApp s [rn] | s == SAuthorizedBy -> do
rn' <- inferPreProp rn
case rn' of
Some SStr (TextLit str) -> pure $ Some SBool (PropSpecific (GuardPassed (RegistryName str)))
_ -> throwErrorIn preProp "expected string literal"
PreApp s [tn, cn, rk] | s == SRowEnforced -> do
tn' <- parseTableName tn
cn' <- parseColumnName cn
Expand Down
10 changes: 10 additions & 0 deletions tests/AnalyzeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,16 @@ spec = describe "analyze" $ do

expectVerified code

describe "authorized-by inlines definitions (regression #1294)" $ do
let code =
[text|
(defconst testname: string 'ks)
(defun test:bool ()
@model[(property (authorized-by testname))]
(enforce-guard (create-module-guard "governance")))
|]
expectVerified code

describe "enforce-one.1" $ do
let code =
[text|
Expand Down

0 comments on commit 8a65a50

Please sign in to comment.