Comments (5)
That looks like a bug in pointer internalization. Here it seems to only handle pointers to structs: https://github.com/gopherjs/gopherjs/blob/fbc70fee0b646e68ae0ecfe4bfef7ddf359cbf45/compiler/prelude/jsmapping.js#L330-L332C14
Moreover, there is no break, so it probably falls through to the next case and does something entirely incorrect.
from gopherjs.
@nevkontakte
is it just me, or is the fix as straightforward as they come?
we just need to remove the if statement, and let it internalize the actual type(regardless of the kind)
from gopherjs.
Unfortunately, no. Pointers in GopherJS are kind of weird and have a lot of special cases (which is probably why they aren't handled properly here). For example, structs and pointers to structs are represented by the same underlying JS object, but pointer to a number is a special kind of object. Depending in which context a pointer is create it may also be a slightly different kind of object. Off the top of my head I won't be able to remember all the rules that apply here. And I'm not even going to touch unsafe.Pointer
, which is a whole separate can of worms :)
One of those days I want to sit down, reverse-engineer and document properly how pointers work, but that day hasn't come yet.
from gopherjs.
how can I help to promote this?
I can help with the research and later write the code if needed
for my use case, this issue is pretty critical to solve, so I do like to push it forward
from gopherjs.
As always, your contribution will be very welcome. If I were to do this, my goal would be to understand how pointers to different types are working (e.g. ints, strings, slices, slice elements, structs, struct fields, etc.). I would probably start with looking at implementation of the address-taking operator (&
). I would also take a look how externalization of pointers works, and see if I can come up with the inverse of it.
Let me know if you have more questions :)
from gopherjs.
Related Issues (20)
- nil pointer dereference
- $GOPATH/src/github.com/gopherjs/gopherjs/js used during compilation HOT 3
- Blocking in a deferred function in a promise crashes HOT 1
- Proposal: Move all Circle CI configuration to run on GitHub Actions instead HOT 2
- Investigate native JS implementation for ParseInt where permitted
- Proposal: Add gopherjsvet tool HOT 6
- math.MaxFloat32 converted to int64 incorrectly:
- Gopherjs returns an error that says no mtime found for source file HOT 3
- Shadowing promoted methods with a struct field is not working HOT 1
- Proposal: change internal type representations to always match the underlying type HOT 1
- Pointer type is not converted correctly when assigned to a struct literal
- Conversion between pointer-to-array types doesn't preserve nil
- `gopherjs test ./...` complains when a subdirectory contains no buildable build tags
- Add Go 1.20 support
- Function expression should be evaluated before arguments
- is there a real world program example for use? HOT 1
- null pointer bug in $externalize HOT 3
- Bug in fallthrough of $internalize pointer types. HOT 1
- Assignment of externalized array doesn't work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gopherjs.