Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPdating OTTO #2

Draft
wants to merge 26 commits into
base: master
Choose a base branch
from
Draft

UPdating OTTO #2

wants to merge 26 commits into from

Conversation

alongir
Copy link
Member

@alongir alongir commented Nov 6, 2024

No description provided.

deoxxa and others added 26 commits July 6, 2023 20:41
runtime.newErrorObject is used to implement the Error constructor, and as such
it takes input from JavaScript via calls like `new Error('xxx')`. The actual
underlying error information is stored in an ottoError object, which is
constructed using newError. newError takes a couple of mandatory arguments,
then treats the remaining parameters (collected as `in ...interface{}`) as a
printf-style format string and parameter list, which it uses to populate the
message field of the returned ottoError object. newErrorObject was passing the
message parameter from the Error function exposed to JavaScript directly
through to newError as the first optional parameter, which led to it being
treated as a format string, which resulted in any code like `throw new
Error('%s')` behaving incorrectly, with the resultant error having a message
like "%!s(MISSING)".

This change fixes this behaviour in the least intrusive way I could find, and
adds some tests to make sure it doesn't come back.

The logic for newErrorObject and newErrorObjectError are very similar, so it
was tempting to try to merge them, but it appears they're used in somewhat
fragile ways with very little test coverage so I'll leave that as a problem
for another day.
Ignore errors when converting a property name to the key type for goMapObject
during a getOwnProperty operation, as a property which fails conversion to the
target's key type could not possibly be a member of it.

fixes robertkrimen#488
Fix lint failures introduced by new 1.53 linters
* Remove naked returns
* Accept times using local time where intended
* Allow unused parameter for now on call method
* Disable depguard which just seems to be noise

Also:
* Correct typo so we use the specified golangci-lint version in CI.
Fix IfStatement Idx0 to point to the right place. I was pointing to the right parenthesis
after the test expression.
Fix Idx0 of ForStatement and ForInStatement to point to the right place which were previously not set.
Fix Idx1 of ObjectLiteral  so that it points to the character immediately after the right brace.

Fix Idx1 of ArrayLiteral so that it points to the character immediately after the right bracket.
Fix Idx1 of ConditionalExpression so that it points to the next character after alternate expression.
Fix Idx1 of SequenceExpression to return Idx1 of the last sequence element, not first.
Fix Idx0 of unary expression to point to the start of operand in case of a postfix operator.
Fix Idx1 of VariableExpression so that it points to the character right after the name literal if the
expression does not have an initializer.
Fix the positions of various statements:
* Fix Idx1 of BranchStatement so that it points to the character after the label if Label exists,
  or the one after Token if Label does not exist.
* Fix Idx1 of LabelledStatement so that it points to the character after the statement.
* Fix Idx1 of ReturnStatement so that it points to the character after the argument if
  Argument exists, or the one after return keyword if Argument does not exist.
* Set Idx0 of SwitchStatement and fix Idx1 of SwitchStatement so that it points to the
  character after the right brace.
* Fix Idx0 of ThrowStatement to point to the start of throw keyword and fix Idx1 of
  ThrowStatement so that it points to the next character after Argument.
* Fix Idx1 of TryStatement to point to the character after Finally if Finally exists, or after Catch
  if Finally does not exist.
* Set Idx0 of WithStatement which was not previously set.
* Set WhileStatement.While so that Idx0 points to the right place.
* Set Idx0 of DoWhileStatement and fix Idx1 to point to the next character after the right
  parenthesis.
Fix Begin of Comment to point to the position of the opening slash.
Adds startsWith method to the String builtins.
Leverage  `trimRight` and `trimLeft` functions to provide `trimStart` and `trimEnd`.
Update go, golangci-lint and action versions.

Address new lint failures flagged by updated golangci-lint version.
Adds support for `Object.values()`
Add support for trailing comma after the last argument of a method call.
Fix the checks for ID_Start & ID_Continue to match the definitions in
https://www.unicode.org/reports/tr31/
In the specific corner case where a regex contains a flag but is not
followed by any symbols, the ast.RegExpLiteral.Literal value would drop
(part of) that flag.

This happens because the p.next() call during the parsing of the flag
wouldn't actually advance the p.chrOffset, and thus endOffset would be
erroneously adjusted.

The fix is just to use the current p.chrOffset and then call p.next()
afterwards.
Update to the oldest supported release of go v1.22 at this time.

Update golangci-lint to 1.61.0 and address all issues.

Update actions to the latest versions.
Fix string slice and replace so they work correctly with utf8
characters.

Fixes robertkrimen#534
Update goreleaser args to use the new non-deprecated --clean.
Clean up readme apply fixes flagged by markdown linter and updating
URLs.
avoid panic-ing when the error type isn't recognized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants