<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/go-git.git/src/go/constant, branch dev.inline</title>
<subtitle>github.com: golang/go
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/'/>
<entry>
<title>go/constant: follow-up for https://go-review.googlesource.com/32870</title>
<updated>2016-11-07T20:59:49+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2016-11-07T19:20:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=1a279b34f674369c05694bd2d8e493ec2d3bba97'/>
<id>1a279b34f674369c05694bd2d8e493ec2d3bba97</id>
<content type='text'>
For #17812.

Change-Id: I58411aaa0e8b2250a16ddb20c951e39da3d601e8
Reviewed-on: https://go-review.googlesource.com/32872
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For #17812.

Change-Id: I58411aaa0e8b2250a16ddb20c951e39da3d601e8
Reviewed-on: https://go-review.googlesource.com/32872
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: improved fatal error messages</title>
<updated>2016-11-07T19:09:21+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2016-11-07T18:43:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=4eb9832724e94d04cd737ac2554cf02a79d87f23'/>
<id>4eb9832724e94d04cd737ac2554cf02a79d87f23</id>
<content type='text'>
Fixes #17812.

Change-Id: I08202165dd3f72ae04420e7b6129b8b689e74f5c
Reviewed-on: https://go-review.googlesource.com/32870
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #17812.

Change-Id: I08202165dd3f72ae04420e7b6129b8b689e74f5c
Reviewed-on: https://go-review.googlesource.com/32870
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: document that BinaryOp doesn't handle comparisons or shifts</title>
<updated>2016-11-05T23:59:04+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2016-11-05T20:14:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=2b445c76453ee79d02ea50f50f619d8f7250fa87'/>
<id>2b445c76453ee79d02ea50f50f619d8f7250fa87</id>
<content type='text'>
Fixes #17797.

Change-Id: I544df81c4bcf3cbd36a793be40050f14f9a9974f
Reviewed-on: https://go-review.googlesource.com/32761
Reviewed-by: Dominik Honnef &lt;dominik@honnef.co&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #17797.

Change-Id: I544df81c4bcf3cbd36a793be40050f14f9a9974f
Reviewed-on: https://go-review.googlesource.com/32761
Reviewed-by: Dominik Honnef &lt;dominik@honnef.co&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: document that Value.String and ExactString return quoted strings</title>
<updated>2016-09-07T04:28:35+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2016-09-07T00:26:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=238274df4eee1752f51b288a11eddaf5365123bf'/>
<id>238274df4eee1752f51b288a11eddaf5365123bf</id>
<content type='text'>
This has always been the case but it was not obvious from the documentation.
The reason for the quoting is that String() may return an abbreviated string,
starting with double-quote (") but ending in ... (w/o a quote). The missing
quote indicates the abbreviation (in contrast to a string ending in ...").

constant.StringVal can be used to obtain the unquoted string of a String Value.

Change-Id: Id0ba45b6ff62b3e024386ba8d907d6b3a4fcb6d7
Reviewed-on: https://go-review.googlesource.com/28576
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This has always been the case but it was not obvious from the documentation.
The reason for the quoting is that String() may return an abbreviated string,
starting with double-quote (") but ending in ... (w/o a quote). The missing
quote indicates the abbreviation (in contrast to a string ending in ...").

constant.StringVal can be used to obtain the unquoted string of a String Value.

Change-Id: Id0ba45b6ff62b3e024386ba8d907d6b3a4fcb6d7
Reviewed-on: https://go-review.googlesource.com/28576
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>math/big: special-case a 0 mantissa during Rat parsing</title>
<updated>2016-06-24T20:51:06+00:00</updated>
<author>
<name>Nathan VanBenschoten</name>
<email>nvanbenschoten@gmail.com</email>
</author>
<published>2016-06-23T23:46:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=5e43dc943a9265ec65690242eb8076727c18a958'/>
<id>5e43dc943a9265ec65690242eb8076727c18a958</id>
<content type='text'>
Previously, a 0 mantissa was special-cased during big.Float
parsing, but not during big.Rat parsing. This meant that a value
like 0e9999999999 would parse successfully in big.Float.SetString,
but would hang in big.Rat.SetString. This discrepancy became an
issue in https://golang.org/src/go/constant/value.go?#L250,
where the big.Float would report an exponent of 0, so
big.Rat.SetString would be used and would subsequently hang.

A Go Playground example of this is https://play.golang.org/p/3fy28eUJuF

The solution is to special-case a zero mantissa during big.Rat
parsing as well, so that neither big.Rat nor big.Float will hang when
parsing a value with 0 mantissa but a large exponent.

This was discovered using go-fuzz on CockroachDB:
https://github.com/cockroachdb/go-fuzz/blob/master/examples/parser/main.go

Fixes #16176

Change-Id: I775558a8682adbeba1cc9d20ba10f8ed26259c56
Reviewed-on: https://go-review.googlesource.com/24430
Reviewed-by: Robert Griesemer &lt;gri@golang.org&gt;
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, a 0 mantissa was special-cased during big.Float
parsing, but not during big.Rat parsing. This meant that a value
like 0e9999999999 would parse successfully in big.Float.SetString,
but would hang in big.Rat.SetString. This discrepancy became an
issue in https://golang.org/src/go/constant/value.go?#L250,
where the big.Float would report an exponent of 0, so
big.Rat.SetString would be used and would subsequently hang.

A Go Playground example of this is https://play.golang.org/p/3fy28eUJuF

The solution is to special-case a zero mantissa during big.Rat
parsing as well, so that neither big.Rat nor big.Float will hang when
parsing a value with 0 mantissa but a large exponent.

This was discovered using go-fuzz on CockroachDB:
https://github.com/cockroachdb/go-fuzz/blob/master/examples/parser/main.go

Fixes #16176

Change-Id: I775558a8682adbeba1cc9d20ba10f8ed26259c56
Reviewed-on: https://go-review.googlesource.com/24430
Reviewed-by: Robert Griesemer &lt;gri@golang.org&gt;
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: fix typos in MakeFromLiteral docs</title>
<updated>2016-03-01T06:04:27+00:00</updated>
<author>
<name>Matthew Dempsky</name>
<email>mdempsky@google.com</email>
</author>
<published>2016-03-01T06:01:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=86235d5dd7b2dbbe3ec94f48276af96c7ed78a5a'/>
<id>86235d5dd7b2dbbe3ec94f48276af96c7ed78a5a</id>
<content type='text'>
Change-Id: I99c737415a082df883a9c12cdb43bdd5a1b9a8ad
Reviewed-on: https://go-review.googlesource.com/20082
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I99c737415a082df883a9c12cdb43bdd5a1b9a8ad
Reviewed-on: https://go-review.googlesource.com/20082
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: fix doc strings</title>
<updated>2016-02-18T17:44:29+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2016-02-18T17:42:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=c51f9173ad2711f5b1a5af9d95dae9e711e13ebb'/>
<id>c51f9173ad2711f5b1a5af9d95dae9e711e13ebb</id>
<content type='text'>
Fixes #14357.

Change-Id: I91acff0b0cc7be2bcbad68925a19a437dbd4c83d
Reviewed-on: https://go-review.googlesource.com/19620
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #14357.

Change-Id: I91acff0b0cc7be2bcbad68925a19a437dbd4c83d
Reviewed-on: https://go-review.googlesource.com/19620
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: fix String() implementation</title>
<updated>2016-02-08T23:10:00+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2016-02-08T22:50:45+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=41191e192cb3d499ca8a2552117029493c6be1a9'/>
<id>41191e192cb3d499ca8a2552117029493c6be1a9</id>
<content type='text'>
Fixes #14262.

Change-Id: Id590995dd4460e81f6b91bcfb3f02515a97650fe
Reviewed-on: https://go-review.googlesource.com/19361
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes #14262.

Change-Id: Id590995dd4460e81f6b91bcfb3f02515a97650fe
Reviewed-on: https://go-review.googlesource.com/19361
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: use Float.Rat method instead of doing it manually</title>
<updated>2015-12-16T00:24:11+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2015-12-15T22:17:56+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=3cc24aa9ab06a57751c08e8bfeb9fc84e82e1ca5'/>
<id>3cc24aa9ab06a57751c08e8bfeb9fc84e82e1ca5</id>
<content type='text'>
Also fixed conversion bug and added corresponding test case.

Change-Id: I26f143fbc8d40a6d073ecb095e61b461495f3d68
Reviewed-on: https://go-review.googlesource.com/17872
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also fixed conversion bug and added corresponding test case.

Change-Id: I26f143fbc8d40a6d073ecb095e61b461495f3d68
Reviewed-on: https://go-review.googlesource.com/17872
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>go/constant: switch to floating-point representation when fractions become too large</title>
<updated>2015-12-14T23:42:01+00:00</updated>
<author>
<name>Robert Griesemer</name>
<email>gri@golang.org</email>
</author>
<published>2015-12-03T01:41:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/go-git.git/commit/?id=d0c17461a785a03781e4cdbd18f7f3ba04d4b9db'/>
<id>d0c17461a785a03781e4cdbd18f7f3ba04d4b9db</id>
<content type='text'>
Use two internal representations for Float values (similar to what is done
for Int values). Transparently switch to a big.Float representation when
big.Rat values become unwieldy. This is almost never needed for real-world
programs but it is trivial to create test cases that cannot be handled with
rational arithmetic alone.

As a consequence, the go/constant API semantics changes slightly: Until now,
a value could always be represented in its "smallest" form (e.g., float values
that happened to be integers would be represented as integers). Now, constant
Kind depends on how the value was created, rather than its actual value. (The
reason why we cannot automatically "normalize" values to their smallest form
anymore is because floating-point numbers are not exact in general; and thus
normalization is often not possible in the first place, or would throw away
precision when it is not desired.) This has repercussions as to how constant
Values are used go/types and required corresponding adjustments.

Details of the changes:

go/constant package:
- use big.Rat and big.Float values to represent floating-point values
  (internal change)
- changed semantic of Value.Kind accordingly
- String now returns a short, human-readable form of a value
  (this leads to better error messages in go/types)
- added ToInt, ToFloat, and ToComplex conversion functions
- added ExactString to obtain an exact string form of a value

go/types:
- adjusted and simplified implementation of representableConst
- adjusted various places where Value.Kind was expected to be "smallest"
  by calling the respective ToInt/Float/Complex conversion functions
- enabled 5 disabled tests in stdlib_test.go that now work

api checker:
- print all constant values in a short human-readable form (floats are
  printed in floating-point form), but also print an exact form if it
  is different from the short form
- adjusted test golden file and go.1.1.text reference file

Fixes #11327.

Change-Id: I492b704aae5b0238e5b7cee13e18ffce61193587
Reviewed-on: https://go-review.googlesource.com/17360
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use two internal representations for Float values (similar to what is done
for Int values). Transparently switch to a big.Float representation when
big.Rat values become unwieldy. This is almost never needed for real-world
programs but it is trivial to create test cases that cannot be handled with
rational arithmetic alone.

As a consequence, the go/constant API semantics changes slightly: Until now,
a value could always be represented in its "smallest" form (e.g., float values
that happened to be integers would be represented as integers). Now, constant
Kind depends on how the value was created, rather than its actual value. (The
reason why we cannot automatically "normalize" values to their smallest form
anymore is because floating-point numbers are not exact in general; and thus
normalization is often not possible in the first place, or would throw away
precision when it is not desired.) This has repercussions as to how constant
Values are used go/types and required corresponding adjustments.

Details of the changes:

go/constant package:
- use big.Rat and big.Float values to represent floating-point values
  (internal change)
- changed semantic of Value.Kind accordingly
- String now returns a short, human-readable form of a value
  (this leads to better error messages in go/types)
- added ToInt, ToFloat, and ToComplex conversion functions
- added ExactString to obtain an exact string form of a value

go/types:
- adjusted and simplified implementation of representableConst
- adjusted various places where Value.Kind was expected to be "smallest"
  by calling the respective ToInt/Float/Complex conversion functions
- enabled 5 disabled tests in stdlib_test.go that now work

api checker:
- print all constant values in a short human-readable form (floats are
  printed in floating-point form), but also print an exact form if it
  is different from the short form
- adjusted test golden file and go.1.1.text reference file

Fixes #11327.

Change-Id: I492b704aae5b0238e5b7cee13e18ffce61193587
Reviewed-on: https://go-review.googlesource.com/17360
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
Run-TryBot: Robert Griesemer &lt;gri@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
