Sorawee Porncharoenwase
320e3d696f
Add a static analyzer for the filter language
...
This commit adds a class AFPSyntaxChecker which can statically analyze
a filter code to detect the following errors:
- unbound variables (which comes in two modes: conservative and liberal,
default to conservative)
- unused variables (disabled by default for compatibilty)
- assignment on built-in identifiers
- function application's arity mismatch
- function application's invalid function name
- non-string literal in the first argument of set / set_var
The existing parser and evaluator are modified as follows:
- The new (caching) evaluator no longer needs to perform variable
hoisting at runtime.
- Note that for array assignment, this changes the semantics.
- The new parser is more lenient, reducing parsing errors.
The static analyzer will catch these errors instead, allowing us
to give a much better error message and reduces the complexity of
the parser.
* The parser now allows function name to be any identifier.
* The parser now allows arity mismatch to occur.
* The parser now allows the first argument of set to be any expression.
Concretely, obvious changes that users will see are:
1. a := [1]; false & (a[] := 2); a[0] === 1
would evaluate to true, while it used to evaluate to the undefined value
due to hoisting
2. f(1)
will now error with 'f is not a valid function' as opposed to
'Unexpected "T_BRACE"'
3. length
will now error with 'Illegal use of built-in identifier "length"'
as opposed to 'Expected a ('
Appendix: conservative and liberal mode
The conservative mode is completely compatible with the current evaluator.
That is,
false & (a := 1); a
will not deem `a` as unbound, though this is actually undesirable because
`a` would then be bound to the troublesome undefined value.
The liberal mode rejects the above pattern by deeming `a` as unbound.
However, it also rejects
true & (a := 1); a
even though (a := 1) is always executed. Since there are several filters
in Wikimedia projects that rely on this behavior, we default the mode
to conservative for now.
Note that even the liberal mode doesn't really respect lexical scope
appeared in some other programming languages (see also T234690).
For instance:
(if true then (a := 1) else (a := 2) end); a
would be accepted by the liberal checker, even though under lexical scope,
`a` would be unbound. However, it is unlikely that lexical scope
will be suitable for the filter language, as most filters in
Wikimedia projects that have user-defined variable do violate lexical scope.
Bug: T260903
Bug: T238709
Bug: T237610
Bug: T234690
Bug: T231536
Change-Id: Ic6d030503e554933f8d220c6f87b680505918ae2
2021-08-31 03:28:24 +02:00
Translation updater bot
32d5fd0218
Localisation updates from https://translatewiki.net .
...
Change-Id: Ifcff6e49b0690ebd9dca0a897d49f83f20dbb6a1
2021-08-30 08:19:21 +02:00
Translation updater bot
691e47a4a6
Localisation updates from https://translatewiki.net .
...
Change-Id: I1111bf7a2410c9fef6f3d4b1db6ba2bd759bd705
2021-08-26 08:35:01 +02:00
Translation updater bot
aafbd68667
Localisation updates from https://translatewiki.net .
...
Change-Id: I24e6daae9e8909c7f0935ba53f02e2901388ce06
2021-08-24 10:16:42 +02:00
Translation updater bot
5c3fbcfb83
Localisation updates from https://translatewiki.net .
...
Change-Id: I7c4e7977b632f8989b559c28f02d6bc81b7c0e14
2021-08-23 09:03:19 +02:00
Translation updater bot
052240a5a5
Localisation updates from https://translatewiki.net .
...
Change-Id: I60b9c7326f8d326d932f1ebe3ccc0e51396d727d
2021-08-20 08:23:36 +02:00
Amir Aharoni
e03467102c
Remove two unused messages
...
It looks like they were removed in 2008:
6c7b701cc2
Change-Id: I5d91d846523307d8a3adb104503d255d8c726ed8
2021-08-19 22:29:53 +03:00
Translation updater bot
d955f2f050
Localisation updates from https://translatewiki.net .
...
Change-Id: Ieb79b02caef2dafe7d3fe32b588ec1095b3366a2
2021-08-18 08:13:08 +02:00
Translation updater bot
ce420438d8
Localisation updates from https://translatewiki.net .
...
Change-Id: I8b23a371a1884e7242b970db6042bd6234f6f940
2021-08-16 08:15:32 +02:00
Translation updater bot
67528ede69
Localisation updates from https://translatewiki.net .
...
Change-Id: Iee1758f64d041c6f7b9f12555aa37cdc2b42e50a
2021-08-12 08:09:13 +02:00
Translation updater bot
e6eafdf496
Localisation updates from https://translatewiki.net .
...
Change-Id: I986c4c7c229c0808b6b374a143e42fd6c169faf2
2021-08-11 08:18:59 +02:00
Translation updater bot
d512f01e8f
Localisation updates from https://translatewiki.net .
...
Change-Id: I2ed4e9d2c6889b0621010a00eeb10b83444d16b9
2021-08-10 08:06:15 +02:00
Translation updater bot
cd7958ba60
Localisation updates from https://translatewiki.net .
...
Change-Id: Ieb3481038beb857b0eabbae1035af852e92c00cd
2021-08-09 08:22:54 +02:00
Translation updater bot
4be9ef8332
Localisation updates from https://translatewiki.net .
...
Change-Id: Ia5d42d3b38e18201020a9debb729c753fe61344a
2021-08-06 08:13:09 +02:00
Translation updater bot
6af66eba3d
Localisation updates from https://translatewiki.net .
...
Change-Id: I4e81fa4d3dbe513540fc6470020c3329cebb4211
2021-08-04 08:14:28 +02:00
Translation updater bot
1dfb191585
Localisation updates from https://translatewiki.net .
...
Change-Id: I89b8759cf45e79debf47d73608f60f8c52bc2ddc
2021-08-03 08:11:19 +02:00
Translation updater bot
455b4d1a6d
Localisation updates from https://translatewiki.net .
...
Change-Id: I05f20f4d65e5f080fef97adcff8cf53339953d51
2021-07-30 08:27:11 +02:00
Translation updater bot
122862cedc
Localisation updates from https://translatewiki.net .
...
Change-Id: I637a0f345e22bb1c41ac9c167437562a94e90310
2021-07-26 08:11:26 +02:00
Translation updater bot
274be621ef
Localisation updates from https://translatewiki.net .
...
Change-Id: If660263b08f22a3d8cd84126ed3d108ea136e6ee
2021-07-22 08:12:51 +02:00
Translation updater bot
ff5ada68aa
Localisation updates from https://translatewiki.net .
...
Change-Id: I3e36ba4d1e8b53e439b9329dbce9f41391fd949d
2021-07-19 08:15:08 +02:00
Translation updater bot
708ae9a76d
Localisation updates from https://translatewiki.net .
...
Change-Id: Ia7185f1946c5cb08a3fef63708b12ab3f08a8416
2021-07-16 08:43:08 +02:00
Translation updater bot
6133a26f66
Localisation updates from https://translatewiki.net .
...
Change-Id: Iea0fda8e87dddb1c08c9f7653ea05cf485418c62
2021-07-15 08:11:39 +02:00
Translation updater bot
ee583dc212
Localisation updates from https://translatewiki.net .
...
Change-Id: Ia10387670f4da80ba279d00321cd2e278333bb13
2021-07-14 08:02:33 +02:00
Translation updater bot
ab1128afde
Localisation updates from https://translatewiki.net .
...
Change-Id: I2bc8ce57e939be53d151f264b7b916f546c8798b
2021-07-13 08:11:20 +02:00
Translation updater bot
28b09f6e21
Localisation updates from https://translatewiki.net .
...
Change-Id: I8620632dcc352ab4a94e5c9bef5945dcec2838c2
2021-07-12 08:05:46 +02:00
Translation updater bot
47158f6d26
Localisation updates from https://translatewiki.net .
...
Change-Id: Icd7b1407f9216d7d15ba425995d806f0ccf62626
2021-07-08 08:46:21 +02:00
Translation updater bot
3b699cd53b
Localisation updates from https://translatewiki.net .
...
Change-Id: I6fa144789bdac812e5cd77f16d82b793dba4676c
2021-07-07 08:07:35 +02:00
Translation updater bot
66103a441e
Localisation updates from https://translatewiki.net .
...
Change-Id: I49142d8ba7c7dfba61c50d7bf8bc7b8c79d2ab34
2021-07-06 08:38:05 +02:00
Translation updater bot
02b755d40b
Localisation updates from https://translatewiki.net .
...
Change-Id: If32adbbd0b1b224840452ac7b22b468a7464ccdd
2021-07-05 08:06:20 +02:00
Translation updater bot
6dc2c068b5
Localisation updates from https://translatewiki.net .
...
Change-Id: If8edba4e6f02ea70bd04560be865d6491d130f7d
2021-07-02 08:30:46 +02:00
Translation updater bot
2b1de9ef11
Localisation updates from https://translatewiki.net .
...
Change-Id: Iad7177f8703306251cd600b8690894b734e6c7ce
2021-06-30 08:25:44 +02:00
Translation updater bot
3b0eadd666
Localisation updates from https://translatewiki.net .
...
Change-Id: I6cd76ac36ae88fec74fd32ecb7baa25333f67874
2021-06-28 09:22:21 +02:00
Translation updater bot
a52ebcf221
Localisation updates from https://translatewiki.net .
...
Change-Id: I27bda07624cec34e8a19a6d974ee49f93c128f17
2021-06-21 14:11:06 +02:00
Translation updater bot
98dee510fb
Localisation updates from https://translatewiki.net .
...
Change-Id: I6021746b15ab9873e14f9bb36c3b1fac9ffeb6a7
2021-06-18 08:20:09 +02:00
Translation updater bot
05f913952b
Localisation updates from https://translatewiki.net .
...
Change-Id: I8df697d1846f890d8e1edfedf652df54ccf9d6ce
2021-06-16 08:19:06 +02:00
Translation updater bot
829d97b1ed
Localisation updates from https://translatewiki.net .
...
Change-Id: If8908b167b231e864c9de62337869464cccf99bd
2021-06-15 08:31:48 +02:00
Translation updater bot
369f9269ae
Localisation updates from https://translatewiki.net .
...
Change-Id: I48f17bb712431bd2db09d53c7b07a285ab5b8db8
2021-06-14 08:35:36 +02:00
Translation updater bot
e5af5e0ce1
Localisation updates from https://translatewiki.net .
...
Change-Id: I24c9b57cb63e05606380062d8dec0500fdf46c48
2021-06-09 08:27:58 +02:00
Translation updater bot
b592251616
Localisation updates from https://translatewiki.net .
...
Change-Id: I340b1f363ce073a61e24971abf176c83ae33f267
2021-06-08 08:35:23 +02:00
Translation updater bot
b7a085bacb
Localisation updates from https://translatewiki.net .
...
Change-Id: Ib6175679a947805cdb92701275e367ca3ca01653
2021-06-07 08:40:56 +02:00
Translation updater bot
f0136ad0ee
Localisation updates from https://translatewiki.net .
...
Change-Id: I39d36b47dfa7ddd3c964edf3941fcbf66b9ea055
2021-06-04 08:35:32 +02:00
Translation updater bot
e642d954a3
Localisation updates from https://translatewiki.net .
...
Change-Id: I71c785186d3d01430a69ddaf5169c4287949c5d1
2021-06-01 08:34:12 +02:00
Translation updater bot
9ddd1affa7
Localisation updates from https://translatewiki.net .
...
Change-Id: I78146b2b666eba71cd803dd9dd7e7b4cf0204a66
2021-05-31 08:29:28 +02:00
Translation updater bot
fa325f1ea5
Localisation updates from https://translatewiki.net .
...
Change-Id: I359f465b4f1ed9c8c2e881cc0d9f3088f62d1792
2021-05-27 12:04:28 +02:00
Translation updater bot
3a8a4849b2
Localisation updates from https://translatewiki.net .
...
Change-Id: Ibfb09f7afdca631a09622042f75824bfc380984d
2021-05-26 09:03:30 +02:00
Translation updater bot
642af0440d
Localisation updates from https://translatewiki.net .
...
Change-Id: I0a2f9032d48d03752a5214e789eb70151981ee18
2021-05-25 08:50:27 +02:00
Translation updater bot
446c36ff06
Localisation updates from https://translatewiki.net .
...
Change-Id: I687d47f81aa66502f8bca4f55598c475c3b77d0e
2021-05-24 09:52:10 +02:00
Translation updater bot
c544392c0f
Localisation updates from https://translatewiki.net .
...
Change-Id: Ided8798d3fc8b0e70a931ff8ab43e685a3123de1
2021-05-21 08:33:12 +02:00
Translation updater bot
6ce61e71d2
Localisation updates from https://translatewiki.net .
...
Change-Id: Ia9f0cb7ae648a0473a87143a5e2e8bd59d26c33a
2021-05-20 09:09:09 +02:00
Translation updater bot
41b885b50a
Localisation updates from https://translatewiki.net .
...
Change-Id: I6b75a6c728344eeb37c5a12aacd490502070938e
2021-05-19 08:41:39 +02:00