Closed Bug 1297090 Opened 9 years ago Closed 1 year ago

Local variable 'module' treated as keyword

Categories

(Webtools :: Searchfox, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mccr8, Assigned: arai)

References

Details

Attachments

(1 file, 1 obsolete file)

47 bytes, text/x-github-pull-request
Details | Review
The function nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest) has a local variable named 'module', which is treated as a keyword (highlighted blue, does not highlight uses when hovering over it with the mouse). http://searchfox.org/mozilla-central/source/dom/base/nsScriptLoader.cpp#2027
I think "module" will be a keyword in C++0something. I guess ideally Searchfox would detect what version of C++ you're compiling with, but it doesn't seem worth it.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX

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.

  • final
  • override
  • transaction_safe
  • transaction_safe_dynamic
  • import
  • module

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
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
See Also: → 1781179

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: nobody → arai.unmht
Status: REOPENED → ASSIGNED
Depends on: 1781179
See Also: 1781179
Attached file GitHub Pull Request (obsolete) —

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.

See Also: → 1593836

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:

  • includes is a keyword but is allowed for operation name,
  • any is 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

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

with making everything contextual, this won't conflict with bug 1781179

No longer depends on: 1781179
Attachment #9407799 - Attachment is obsolete: true
Attached file GitHub Pull Request
Status: ASSIGNED → RESOLVED
Closed: 9 years ago1 year ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: