Page MenuHomePhabricator

Using function name as a user-defined variable
Closed, ResolvedPublic

Description

The following code is currently well-formed:

length := 1

But length can't ever be used. In particular:

length := 1;
length

will cause the parser to look for a function application, which doesn't exist, resulting in a parsing error.

There are two possible solutions for this problem:

  1. Forbid users from defining a variable with a function name entirely.
  2. Have two namespaces properly: one for function names and one for variable names (there's no higher-order function in this language anyway...) and change the parser to allow the above filter.

Event Timeline

Hah, thanks for reporting, I thought we were already forbidding this. IMHO we should go with (1.), which is easy to implement. That doesn't exclude (2.) in the long term, if we want to go for it.

Change 547871 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Forbid assignments where the LHS is a built-in identifier

https://gerrit.wikimedia.org/r/547871

Change 547871 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Forbid assignments where the LHS is a built-in identifier

https://gerrit.wikimedia.org/r/547871

Daimona removed a project: Patch-For-Review.