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

compiler: fix incorrect emitted Javascript for type switch #683

Merged
merged 3 commits into from Sep 6, 2017
Jump to file or symbol
Failed to load files and symbols.
+4 −3
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

js: Make test cases non-fatal.

There's no reason for these to be fatal. We can continue running the
test further if any one of them fails. That way, if there are multiple
failures, it's easier to see them all at once.

Separate var x from the switch by a blank line, since it's used by both
switch and the if statement below. Having it without a blank line makes
it seem that it's only needed for the switch.
  • Loading branch information...
dmitshur committed Sep 6, 2017
commit d58cd815e4ca775cf48b206c2e7ecdee3cd1b6d5
View
@@ -579,20 +579,21 @@ func TestTypeSwitchJSObject(t *testing.T) {
want := "bar"
if got := obj.Get("foo").String(); got != want {
t.Fatalf("Direct access to *js.Object field gave %q, want %q", got, want)
t.Errorf("Direct access to *js.Object field gave %q, want %q", got, want)
}
var x interface{} = obj
switch x := x.(type) {
case *js.Object:
if got := x.Get("foo").String(); got != want {
t.Fatalf("Value passed through interface and type switch gave %q, want %q", got, want)
t.Errorf("Value passed through interface and type switch gave %q, want %q", got, want)
}
}
if y, ok := x.(*js.Object); ok {
if got := y.Get("foo").String(); got != want {
t.Fatalf("Value passed through interface and type assert gave %q, want %q", got, want)
t.Errorf("Value passed through interface and type assert gave %q, want %q", got, want)
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.