stacks-network / stacks-core

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

Improve type-checker error #3350

Open obycode opened 1 year ago

obycode commented 1 year ago

If a uint expression is passed as the max_length parameter to as-max-length? which is not a uint literal, we get the following error that is confusing to developers:

error: expecting expression of type 'uint', found 'uint'

Describe the solution you'd like

low's suggestion from a Discord discussion sounds good to me:

error: expecting 'uint' literal, found expression of type 'uint'

That, together with correctly identifying that specific parameter, and not the whole as-max-length? expression, would make this a very clear error.

Additional context

Simple reproducer:

(define-private (test1 (l (list 20 uint)) (n uint))
    (as-max-len? l n)
)
jcnelson commented 1 year ago

Temporarily assigning to @obycode