Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid double implicit type conversion on deferred built-in arguments. #998

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

Merged
merged 1 commit into from
Mar 18, 2021

Conversation

nevkontakte
Copy link
Member

Because certain built-in function may not be translated into callable
expressions, GopherJS wraps them into a proxy lambda function when
necessary. Prior to this change it was incorrectly inferring argument
types for this proxy function, which led to a possible double implicit
type conversion and a runtime error in the generated code.

With this change, the types are assigned in accordance with what the
deferred function expects, and therefore no double conversion will
happen.

This change allows TesSliceNoCycle in encoding/json to pass under
Go 1.16.

Updates #989.

Because certain built-in function may not be translated into callable
expressions, GopherJS wraps them into a proxy lambda function when
necessary. Prior to this change it was incorrectly inferring argument
types for this proxy function, which led to a possible double implicit
type conversion and a runtime error in the generated code.

With this change, the types are assigned in accordance with what the
deferred function expects, and therefore no double conversion will
happen.

This change allows TesSliceNoCycle in `encoding/json` to pass under
Go 1.16.
@nevkontakte nevkontakte requested a review from flimzy March 17, 2021 18:14
@nevkontakte nevkontakte merged commit 163a579 into gopherjs:go1.16-stdlib Mar 18, 2021
nevkontakte added a commit to nevkontakte/gopherjs that referenced this pull request Nov 21, 2021
Built-ins and `js.Object` methods are represented by JS expressions that
may not be straightforward function calls, or reference functions
defined in the prelude. In such cases, the callable expression must be
wrapped in a lambda.

gopherjs#998 has fixed a similar issue
for the `defer` keyword, and this change generalizes the same fix for
the `go` keyword.

Fixes gopherjs#547.
nevkontakte added a commit to nevkontakte/gopherjs that referenced this pull request Nov 21, 2021
Built-ins and `js.Object` methods are represented by JS expressions that
may not be straightforward function calls, or reference functions
defined in the prelude. In such cases, the callable expression must be
wrapped in a lambda.

gopherjs#998 has fixed a similar issue
for the `defer` keyword, and this change generalizes the same fix for
the `go` keyword.

Fixes gopherjs#547.
nevkontakte added a commit to nevkontakte/gopherjs that referenced this pull request Nov 21, 2021
Built-ins and `js.Object` methods are represented by JS expressions that
may not be straightforward function calls, or reference functions
defined in the prelude. In such cases, the callable expression must be
wrapped in a lambda.

gopherjs#998 has fixed a similar issue
for the `defer` keyword, and this change generalizes the same fix for
the `go` keyword.

Fixes gopherjs#547.
nevkontakte added a commit to nevkontakte/gopherjs that referenced this pull request Dec 19, 2021
Built-ins and `js.Object` methods are represented by JS expressions that
may not be straightforward function calls, or reference functions
defined in the prelude. In such cases, the callable expression must be
wrapped in a lambda.

gopherjs#998 has fixed a similar issue
for the `defer` keyword, and this change generalizes the same fix for
the `go` keyword.

Fixes gopherjs#547.
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.

2 participants