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

Commit 11065e6

Browse filesBrowse files
committed
Fix fc.formatExpr("%f") to work with type param types.
%f instructs the format to "flatten" all numeric types into a JS number. To do that correctly, you need to know whether the passed number is 64-bit or less. In case of the type parameter we pass the type constructor as a second argument to determine that at runtime.
1 parent ad18f2c commit 11065e6
Copy full SHA for 11065e6

File tree

Expand file treeCollapse file tree

2 files changed

+18
-15
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+18
-15
lines changed

‎compiler/expressions.go

Copy file name to clipboardExpand all lines: compiler/expressions.go
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,11 +1565,16 @@ func (fc *funcContext) formatExprInternal(format string, a []interface{}, parens
15651565
out.WriteString(strconv.FormatInt(d, 10))
15661566
return
15671567
}
1568-
if is64Bit(fc.pkgCtx.TypeOf(e).Underlying().(*types.Basic)) {
1568+
if t, ok := fc.pkgCtx.TypeOf(e).Underlying().(*types.Basic); ok && is64Bit(t) {
15691569
out.WriteString("$flatten64(")
15701570
writeExpr("")
15711571
out.WriteString(")")
15721572
return
1573+
} else if t, ok := fc.pkgCtx.TypeOf(e).(*types.TypeParam); ok {
1574+
out.WriteString("$flatten64(")
1575+
writeExpr("")
1576+
fmt.Fprintf(out, ", %s)", fc.typeName(t))
1577+
return
15731578
}
15741579
writeExpr("")
15751580
case 'h':

‎tests/gorepo/run.go

Copy file name to clipboardExpand all lines: tests/gorepo/run.go
+12-14Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,18 @@ var knownFails = map[string]failReason{
155155
// Failures related to the lack of generics support. Ideally, this section
156156
// should be emptied once https://github.com/gopherjs/gopherjs/issues/1013 is
157157
// fixed.
158-
"typeparam/absdiff2.go": {category: generics, desc: "missing support for unary minus operator"},
159-
"typeparam/absdiff3.go": {category: generics, desc: "missing support for unary minus operator"},
160-
"typeparam/boundmethod.go": {category: generics, desc: "missing support for method expressions with a type param"},
161-
"typeparam/dictionaryCapture.go": {category: generics, desc: "make() doesn't support generic slice types"},
162-
"typeparam/double.go": {category: generics, desc: "make() doesn't support generic slice types"},
163-
"typeparam/index2.go": {category: generics, desc: "missing index operator support for generic types"},
164-
"typeparam/issue47716.go": {category: generics, desc: "unsafe.Sizeof() doesn't work with generic types"},
165-
"typeparam/issue48453.go": {category: generics, desc: "make() doesn't support generic slice types"},
166-
"typeparam/issue49295.go": {category: generics, desc: "len() doesn't support generic pointer to array types"},
167-
"typeparam/issue51303.go": {category: generics, desc: "missing support for range over type parameter"},
168-
"typeparam/nested.go": {category: generics, desc: "missing comparison operator support for generic types"},
169-
"typeparam/typeswitch2.go": {category: generics, desc: "complex types have different print() format"},
170-
"typeparam/typeswitch3.go": {category: generics, desc: "missing support for type switching on generic types"},
171-
"typeparam/typeswitch5.go": {category: generics, desc: "different print() format for floating point types"},
158+
"typeparam/absdiff2.go": {category: generics, desc: "missing support for unary minus operator"},
159+
"typeparam/absdiff3.go": {category: generics, desc: "missing support for unary minus operator"},
160+
"typeparam/boundmethod.go": {category: generics, desc: "missing support for method expressions with a type param"},
161+
"typeparam/double.go": {category: generics, desc: "missing support for range over type parameter"},
162+
"typeparam/index2.go": {category: generics, desc: "missing index operator support for generic types"},
163+
"typeparam/issue47716.go": {category: generics, desc: "unsafe.Sizeof() doesn't work with generic types"},
164+
"typeparam/issue48453.go": {category: generics, desc: "missing support for range over type parameter"},
165+
"typeparam/issue51303.go": {category: generics, desc: "missing support for range over type parameter"},
166+
"typeparam/nested.go": {category: generics, desc: "missing comparison operator support for generic types"},
167+
"typeparam/typeswitch2.go": {category: generics, desc: "complex types have different print() format"},
168+
"typeparam/typeswitch3.go": {category: generics, desc: "missing support for type switching on generic types"},
169+
"typeparam/typeswitch5.go": {category: generics, desc: "different print() format for floating point types"},
172170
}
173171

174172
type failCategory uint8

0 commit comments

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