Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Second enclosed function can't access pointer #402

Copy link
Copy link
@flimzy

Description

@flimzy
Issue body actions

Consider the following code:

package main

import "fmt"

func main() {
    var x int
    go func() {
        fmt.Println(&x)
    }()
    go func() {
        fmt.Println(&x)
    }()
}

The output of 'gopherjs run' is:

$ gopherjs run x.go
gopherjs: Source maps disabled. Use Node.js 4.x with source-map-support module for nice stack traces.
0x1
/home/jonhall/go/src/github.com/flimzy/x/x.go.705403117:1472
        throw err;
        ^

ReferenceError: x$24ptr is not defined
    at $b (/home/jonhall/go/src/github.com/flimzy/x/x.go.705403117:15912:37)
    at $goroutine (/home/jonhall/go/src/github.com/flimzy/x/x.go.705403117:1463:19)
    at $runScheduled [as _onTimeout] (/home/jonhall/go/src/github.com/flimzy/x/x.go.705403117:1504:7)
    at Timer.listOnTimeout (timers.js:92:15)

When I look at the compiled JS output, I see the apparent problem (with line numbers):

15902       $go((function $b() {
15903           var $ptr, _r, x$24ptr, $s, $r;

15909       $go((function $b() {
15910           var $ptr, _r, $s, $r;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.