stacks-network / stacks-core

The Stacks blockchain implementation
https://docs.stacks.co
GNU General Public License v3.0
3.01k stars 674 forks source link

[clarity] Calling non-existent contract within `define-read-only` yields wrong error #4370

Open MicaiahReid opened 9 months ago

MicaiahReid commented 9 months ago

Describe the bug If you make a contract-call? to an undefined contract within a define-read-only block, the error is expecting read-only statements, detected a writing operation rather than indicating that the contract being called does not exist.

Steps To Reproduce Create a contract with the following:

(define-read-only (call-ok-true)
    (ok (contract-call? does_not_exist ok-true)))

Note the error expecting read-only statements, detected a writing operation, rather than something like contract does_not_exist is not defined

Expected behavior To receive a contract does_not_exist is not defined error

Environment (please complete the following information):

obycode commented 3 months ago

This is just a side effect of the fact that the read-only checker runs before the type-checker. I don't think this is necessarily a problem.