Match Solidity identifier regex (#1657).

This commit is contained in:
Richard Moore 2021-06-10 17:47:17 -04:00
parent be20e28de1
commit a6e128f5cc
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

@ -1029,7 +1029,8 @@ function verifyType(type: string): string {
return type; return type;
} }
const regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); // See: https://github.com/ethereum/solidity/blob/1f8f1a3db93a548d0555e3e14cfc55a10e25b60e/docs/grammar/SolidityLexer.g4#L234
const regexIdentifier = new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");
function verifyIdentifier(value: string): string { function verifyIdentifier(value: string): string {
if (!value || !value.match(regexIdentifier)) { if (!value || !value.match(regexIdentifier)) {
logger.throwArgumentError(`invalid identifier "${ value }"`, "value", value); logger.throwArgumentError(`invalid identifier "${ value }"`, "value", value);