-
Notifications
You must be signed in to change notification settings - Fork 705
Description
Copied from hirosystems/clarinet#418 reported by @FriendsFerdinand. I opened a PR to fix this in clarinet, but a similar change should likely be made here, for 2.1, so that this type of problem will cause an error when deploying the contract instead of only reporting a runtime error when it is called.
Original issue:
Consider the following contract where I use try!
as a variable name:
(define-public (call-this (fail bool))
(let (
(try! (try-me fail))
)
(ok true)
)
)
(define-public (try-me (fail bool))
(begin
(asserts! fail (err u999))
(ok true)
)
)
This passes a clarinet check, but when executed on clarinet console returns a RuntimeError:
Runtime Error: Runtime error while interpreting ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.contract-7: Unchecked(NameAlreadyUsed("try!"))
If you use an asserts! instead, it will not pass clarinet check, naming a syntax error.
If I write: (define-data-var try! uint u0)
, then it will return a Runtime error NameAlreadyUsed
after running clarinet check.
Conclusion
I think running clarinet check should be able to detect this kind of error before trying to run the contract code on clarinet console/test.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status