clarity-lang / reference

The Clarity Reference
149 stars 35 forks source link

Identifiers beginning with `u[0-9]` #57

Open obycode opened 1 year ago

obycode commented 1 year ago

Currently, an identifier beginning with a u, followed by one or more digits, then followed by one or more valid identifier characters, [a-zA-Z_-][a-zA-Z0-9_-]*, is illegal. To give a concrete example, this could be a name like u123hello_world. Pre-2.1, with the original parser would give the following error:

error: Expected whitespace or a close parens. Found: 'hello_world'

After 2.1, the parser gives the following error:

error: invalid character, 'h', in uint literal
--> contracts/simple.clar:1:21
(define-public (u123hello_world) (ok true))
                    ^~~~~~~~~~~

An argument could be made to maintain this same behavior, to avoid confusion with unsigned integers, or to allow this type of name in a future version of Clarity.