Match Solidity identifier regex (#1657).
This commit is contained in:
parent
be20e28de1
commit
a6e128f5cc
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user