Age | Commit message (Collapse) | Author |
|
|
|
This removes the awkward String::replace API which was the only String
API which mutated the String and replaces it with a new immutable
version that returns a new String with the replacements applied. This
also fixes a couple of UAFs that were caused by the use of this API.
As an optimization an equivalent StringView::replace API was also added
to remove an unnecessary String allocations in the format of:
`String { view }.replace(...);`
|
|
Our existing implementation did not check the element type of the other
pointer in the constructors and move assignment operators. This meant
that some operations that would require explicit casting on raw pointers
were done implicitly, such as:
- downcasting a base class to a derived class (e.g. `Kernel::Inode` =>
`Kernel::ProcFSDirectoryInode` in Kernel/ProcFS.cpp),
- casting to an unrelated type (e.g. `Promise<bool>` => `Promise<Empty>`
in LibIMAP/Client.cpp)
This, of course, allows gross violations of the type system, and makes
the need to type-check less obvious before downcasting. Luckily, while
adding the `static_ptr_cast`s, only two truly incorrect usages were
found; in the other instances, our casts just needed to be made
explicit.
|
|
|
|
- Fix some places where escaped keywords are (not) allowed.
- Be more strict about parameters for functions with 'use strict'.
- Fix that expressions statements allowed functions and classes.
- Fix that class expressions were not allowed.
- Added a new next_token() method for checking the look ahead.
- Fix that continue labels could jump to non iterating targets.
- Fix that generator functions cannot be declared in if statements.
|
|
And add ZERO WIDTH NO BREAK SPACE to valid whitespace.
|
|
Also recognize additional white space characters.
|
|
Since 'let' is a valid variable name (in non-strict mode) let may not be
the start of a declaration but just an identifier.
|
|
|
|
Also disallow duplicated labels.
|
|
We produce the import and export entries as per the spec. However we do
not yet verify that named things that are exported are declared
somewhere.
|
|
In a module strict mode should be enabled at the start of parsing and we
allow import and export statements.
|
|
If a function is strict (has 'use strict' directive) it cannot have
bindings, cannot have duplicated parameter names and cannot have some
reserved keywords and identifiers as parameter names.
The logic partly applies depending on whether we are already in strict
mode or the function contains 'use strict';
|
|
|
|
This was causing some syntactically wrong inputs to crash and
subsequently broke CI (test262 parser tests).
|
|
This optimizes the algorithm used in source_location_hint and adds a
flag to not print hints in print_errors.
|
|
|
|
When a lexical declaration with the same name as a function exists,
the function is not hoisted (annex B).
|
|
This reverts commit 3411d50737725b382ae526e91a8bbd60656c3323.
It was causing LeakSanitizer on CI to fail, possibly due to a circular
reference.
|
|
When a lexical declaration with the same name as a function exists,
the function is not hoisted (annex B).
|
|
The parser now keeps track of a scope chain so that it can hoist
function declarations to the closest function scope.
|
|
eval only has direct access to the local scope when accessed through
the name eval. This includes locals named eval, because of course it
does.
|
|
Also remove the "m_" prefix from all the public data members.
|
|
|
|
This commit implements parsing for `yield *expr`, and the multiple
ways something can or can't be parsed like that.
Also makes yield-from a TODO in the bytecode generator.
Behold, the glory of javascript syntax:
```js
// 'yield' = expression in generators.
function* foo() {
yield
*bar; // <- Syntax error here, expression can't start with *
}
// 'yield' = identifier anywhere else.
function foo() {
yield
*bar; // Perfectly fine, this is just `yield * bar`
}
```
|
|
Also add some parser tests
|
|
This patch adds an "argument index" field to Identifier AST nodes.
If the Identifier refers to a function parameter in the currently
open function scope, we stash the index of the parameter here.
This will allow us to implement much faster direct access to function
argument variables.
|
|
|
|
|
|
|
|
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
|
|
|
|
|
|
|
|
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)
Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.
We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
|
|
|