aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-25 11:17:43 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-28 23:31:05 +0000
commit1519271a939ad27da133318dc4bde7e6a41a35b5 (patch)
tree38ed60e6d312ce819bf8b4de41428504c27c44df /doc
parent5385e2386b64b10960c1b40113ee7dae271c8369 (diff)
downloadgo-1519271a939ad27da133318dc4bde7e6a41a35b5.tar.gz
go-1519271a939ad27da133318dc4bde7e6a41a35b5.zip
spec: change unsafe.Slice((*T)(nil), 0) to return []T(nil)
Updates #46742. Change-Id: I044933a657cd1a5cdb29863e49751df5fe9c258a Reviewed-on: https://go-review.googlesource.com/c/go/+/331069 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'doc')
-rw-r--r--doc/go_spec.html10
1 files changed, 8 insertions, 2 deletions
diff --git a/doc/go_spec.html b/doc/go_spec.html
index b59b37fd55..e0602418e8 100644
--- a/doc/go_spec.html
+++ b/doc/go_spec.html
@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
- "Subtitle": "Version of Jun 22, 2021",
+ "Subtitle": "Version of Jun 28, 2021",
"Path": "/ref/spec"
}-->
@@ -6790,10 +6790,16 @@ and whose length and capacity are <code>len</code>:
</pre>
<p>
+As a special case, if <code>ptr</code> is <code>nil</code> and <code>len</code> is zero,
+<code>Slice</code> returns <code>nil</code>.
+</p>
+
+<p>
The <code>len</code> argument must be of integer type or an untyped <a href="#Constants">constant</a>.
A constant <code>len</code> argument must be non-negative and <a href="#Representability">representable</a> by a value of type <code>int</code>;
if it is an untyped constant it is given type <code>int</code>.
-If <code>ptr</code> is <code>nil</code> or <code>len</code> is negative at run time,
+At run time, if <code>len</code> is negative,
+or if <code>ptr</code> is <code>nil</code> and <code>len</code> is not zero,
a <a href="#Run_time_panics">run-time panic</a> occurs.
</p>