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 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 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 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.
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#488
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.
Fix the way tester works, move it into the tools directory and clean up
how it processes files including adding more data to the summary about
what failed and why.
Remove the dependencies on perl and make.
inline.pl is replaced by tools/gen-jscore and token/tokenfmt is replaced
by tools/gen-tokens which are both golang text/template utilities.
gen-jscore uses property ordering that matches chromes output ordering
adding missing properties to the Error types.
Local generated documentation have been removed as https://pkg.go.dev/
is more feature rich.
The use of make has been removed as the functionality is now replicated by
standard golang tools go test ./... and go generate ./... as well as integrated
into github actions.
Enable more linters, address the issues and do a major naming refactor
to use golang lower camelCase identifiers for types, functions, methods
and variable names.
Also:
* Clean up inline generation so it doesn't rely on temporary variables.
* Remove unused functions generated by inline.pl.
Fix toInt32, toUint32 conversions which caused test failures on arm64 by
leveraging the power of go casts to simplify the conversion from float64
to integer types.
Update underscore.js to v1.13.6.
BREAKING CHANGE: This changes the behaviour for the following underscore
functions, please see underscore.js documentation for details.
* .template
* .keys
* .after
* .range
* .reduce
* .reduceRight
* .reduceLeft
Fixes#110
Fix the example to clean up watchdog goroutine after either the timeout or the VM completes.
Co-authored-by: Steven Hartland <steven.hartland@multiplay.co.uk>
When putting JavaScript objects into _go*object use exported values.
This reverts PR #467 in favour of this more complete work.
Fixes#118#252
Co-authored-by: Dmitry Panov <dop@itoolabs.com>
While not specified in the ECMA specification the current index has been
typed as number by others, so match this instead of passing as string.
Fixes#177
Use time.UnixMilli instead of UnixNano for time calculations to avoid
underflow / overflow issues.
BREAKING CHANGE: Use a GMT fixed time zone for UTC to mimic toUTCString
behaviour of Javascript which outputs in GMT not UTC.
Fixes#302
In nested do-while statements, a semicolon after the inner `while` threw
a parsing error. This change checks for the optional semicolon.
Co-authored-by: Brian Graham <bcgraham+github@gmail.com>
Add support for direct use of push to go slices without converting to
array using .slice().
Fixes#357
Also:
* Add classGoSlice and use it, to make it clear the type when debugging.
Enable the whitespace linter and fix the errors resulting from it.
Also:
* Remove unneeded golangci-lint config for disabled linters.
* Correct test number for panic in previous commit.
Fix array writes not being persisted by passing in writeable
reflect.Value when available instead of .Interface() which looses that
property.
Also:
* Use value.IsValid() instead of comparison with zero entry.
* Use propertyLength instead of literal.
Fixes#386
Allow pointers to structs in fieldIndexByName.
Also:
* Use reflect.Type.Elem() vs reflect.ValueOf(t).Elem().Type().
* Format bug_test.go to fix lint failure.