Skip to content

Incorrect use of stale cached code #827

Open
@antong

Description

@antong

Go 1.10.2 on Windows, GopherJS 1.10-4 (8dffc02)

Compiling using GOOS=linux gopherjs.exe ....

Assume the following package layout:

  • gojscache/gojscache.go : defines type Foo.
  • gojscache/factory/factory.go : constructs a *gojscache.Foo
  • gojscache/use/main.go: imports gojscache and gojscache/factory. Uses gojscache/factory to construct a *gojscache.Foo.

Now, when modifying the top package to add fields to Foo and rebuilding gojscache/use, Gopherjs doesn't rebuild gojscache/factory. This causes the constructor in gojscache/factory to erroneously omit the newly added fields in Foo, leading to errors such as:

..js:13680 Uncaught TypeError: Cannot read property 'constructor' of undefined
    at Object.$packages.reflect.Value.ptr.object (..js:13680)
    at valueInterface (reflect.go:677)
    at Object.$packages.reflect.Value.ptr.Interface (..js:15774)
    at Object.$packages.fmt.pp.ptr.printValue (print.go:699)
    at Object.$packages.fmt.pp.ptr.printValue (print.go:783)
    at Object.$packages.fmt.pp.ptr.printValue (print.go:853)
    at Object.$packages.fmt.pp.ptr.printArg (print.go:689)
    at Object.$packages.fmt.pp.ptr.doPrintln (print.go:1146)
    at Fprintln (print.go:254)
    at Object.Println (..js:17476)
    at main (main.go:11)
    at $init (..js:18826)
    at $goroutine (..js:1471)
    at $runScheduled (..js:1511)
    at $schedule (..js:1527)
    at $go (..js:1503)
    at ..js:18837
    at ..js:18840

This is fixed by #805 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixNeedsHelpCommunity contributions are welcome for this feature!bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions