Local variable 'module' treated as keyword
Categories
(Webtools :: Searchfox, defect)
Tracking
(Not tracked)
People
(Reporter: mccr8, Assigned: arai)
References
Details
Attachments
(1 file, 1 obsolete file)
| Assignee | ||
Comment 2•1 year ago
|
||
According to https://en.cppreference.com/w/cpp/keyword , module is a contextual keyword, which means it's totally fine to be used as variable name even after C++20.
finaloverridetransaction_safetransaction_safe_dynamicimportmodule
while detecting the context isn't realistic, we could for example do the following:
- make them keyword by default (so, highlight blue)
- if there's analysis record for the token, turn it into symbol syntax
| Assignee | ||
Comment 3•1 year ago
|
||
supporting contextual keyword is also beneficial for ECMAScript, given ECMAScript has many kind of contextual keywords, and being able to highlight them based on the syntax (or actually, whether it's detected as variable or not, by indexer) will make the code easier to read.
I have prototype patch, but it conflicts with bug 1781179, and I think it's better fixing the issue based on bug 1781179's change, I'll wait for it.
| Assignee | ||
Comment 4•1 year ago
|
||
| Assignee | ||
Comment 5•1 year ago
|
||
Rust also has similar concept "weak keywords"
https://doc.rust-lang.org/reference/keywords.html
and bug 1593836 is caused by treating union as strict keyword.
| Assignee | ||
Comment 6•1 year ago
|
||
WebIDL's keywords are also very contextual.
https://webidl.spec.whatwg.org/#idl-grammar
There are some case the contextual keyword being the member name, such as includes and any,
where:
includesis a keyword but is allowed for operation name,anyis not actually keyword, but has special meaning in the type context
https://webidl.spec.whatwg.org/#prod-OperationName
OperationName ::
OperationNameKeyword
identifier
https://webidl.spec.whatwg.org/#prod-SingleType
SingleType ::
DistinguishableType
any
PromiseType
| Assignee | ||
Comment 7•1 year ago
|
||
in order to simplify the handling across language, it may be better just making all keywords "contextual",
which means, whenever the word has corresponding analysis record, it becomes an identifier, and otherwise it's kept as keyword.
As long as the indexer correctly handles the keyword vs identifier, the formatter doesn't have to distinguish them
| Assignee | ||
Comment 8•1 year ago
|
||
with making everything contextual, this won't conflict with bug 1781179
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 9•1 year ago
|
||
| Assignee | ||
Updated•1 year ago
|
Description
•