mirror of
https://github.com/golang/go
synced 2024-11-25 02:57:57 -07:00
implications of stricter type equality:
if both types are named, they must be the same type (arising from the same declaration). R=r,gri DELTA=44 (21 added, 4 deleted, 19 changed) OCL=28436 CL=28577
This commit is contained in:
parent
cd3ab57a9c
commit
917aa35f8f
@ -171,12 +171,12 @@ func dollarString(s, l, r string) string {
|
|||||||
// the context in which the result will be interpreted.
|
// the context in which the result will be interpreted.
|
||||||
type ShellString string;
|
type ShellString string;
|
||||||
func (s ShellString) String() string {
|
func (s ShellString) String() string {
|
||||||
return dollarString(s, "{", "}");
|
return dollarString(string(s), "{", "}");
|
||||||
}
|
}
|
||||||
|
|
||||||
type MakeString string;
|
type MakeString string;
|
||||||
func (s MakeString) String() string {
|
func (s MakeString) String() string {
|
||||||
return dollarString(s, "(", ")");
|
return dollarString(string(s), "(", ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(rsc): parse.Parse should return an os.Error.
|
// TODO(rsc): parse.Parse should return an os.Error.
|
||||||
|
@ -237,7 +237,7 @@ func (tok Token) String() string {
|
|||||||
if str, exists := tokens[tok]; exists {
|
if str, exists := tokens[tok]; exists {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return "token(" + strconv.Itoa(tok) + ")";
|
return "token(" + strconv.Itoa(int(tok)) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ func Redirect(c *Conn, url string) {
|
|||||||
// Redirect to a fixed URL
|
// Redirect to a fixed URL
|
||||||
type redirectHandler string
|
type redirectHandler string
|
||||||
func (url redirectHandler) ServeHTTP(c *Conn, req *Request) {
|
func (url redirectHandler) ServeHTTP(c *Conn, req *Request) {
|
||||||
Redirect(c, url);
|
Redirect(c, string(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
// RedirectHandler returns a request handler that redirects
|
// RedirectHandler returns a request handler that redirects
|
||||||
|
@ -15,7 +15,7 @@ type Error interface {
|
|||||||
// Error.
|
// Error.
|
||||||
type ErrorString string
|
type ErrorString string
|
||||||
func (e ErrorString) String() string {
|
func (e ErrorString) String() string {
|
||||||
return e
|
return string(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewError converts s to an ErrorString, which satisfies the Error interface.
|
// NewError converts s to an ErrorString, which satisfies the Error interface.
|
||||||
@ -27,7 +27,7 @@ func NewError(s string) Error {
|
|||||||
// wrappers to convert the error number into an Error.
|
// wrappers to convert the error number into an Error.
|
||||||
type Errno int64
|
type Errno int64
|
||||||
func (e Errno) String() string {
|
func (e Errno) String() string {
|
||||||
return syscall.Errstr(e)
|
return syscall.Errstr(int64(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrnoToError converts errno to an Error (underneath, an Errno).
|
// ErrnoToError converts errno to an Error (underneath, an Errno).
|
||||||
|
@ -181,7 +181,7 @@ func New(fmap FormatterMap) *Template {
|
|||||||
|
|
||||||
// Generic error handler, called only from execError or parseError.
|
// Generic error handler, called only from execError or parseError.
|
||||||
func error(errors chan os.Error, line int, err string, args ...) {
|
func error(errors chan os.Error, line int, err string, args ...) {
|
||||||
errors <- ParseError{fmt.Sprintf("line %d: %s", line, fmt.Sprintf(err, args))};
|
errors <- ParseError{os.ErrorString(fmt.Sprintf("line %d: %s", line, fmt.Sprintf(err, args)))};
|
||||||
runtime.Goexit();
|
runtime.Goexit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ func validDelim(d []byte) bool {
|
|||||||
// the error.
|
// the error.
|
||||||
func (t *Template) Parse(s string) os.Error {
|
func (t *Template) Parse(s string) os.Error {
|
||||||
if !validDelim(t.ldelim) || !validDelim(t.rdelim) {
|
if !validDelim(t.ldelim) || !validDelim(t.rdelim) {
|
||||||
return ParseError{fmt.Sprintf("bad delimiter strings %q %q", t.ldelim, t.rdelim)}
|
return ParseError{os.ErrorString(fmt.Sprintf("bad delimiter strings %q %q", t.ldelim, t.rdelim))}
|
||||||
}
|
}
|
||||||
t.buf = io.StringBytes(s);
|
t.buf = io.StringBytes(s);
|
||||||
t.p = 0;
|
t.p = 0;
|
||||||
|
@ -236,7 +236,7 @@ func readinfofile(name string) ([]zonetime, os.Error) {
|
|||||||
|
|
||||||
Error:
|
Error:
|
||||||
if tzerr, ok := err.(TimeZoneError); ok {
|
if tzerr, ok := err.(TimeZoneError); ok {
|
||||||
tzerr.ErrorString += ": " + name
|
tzerr.ErrorString = os.ErrorString(tzerr.String() + ": " + name)
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -40,14 +40,11 @@ func main() {
|
|||||||
panicln("type of f is", t, "want", want);
|
panicln("type of f is", t, "want", want);
|
||||||
}
|
}
|
||||||
|
|
||||||
want = typeof(x);
|
want = typeof(a);
|
||||||
if t := typeof(+a); t != want {
|
if t := typeof(+a); t != want {
|
||||||
panicln("type of +a is", t, "want", want);
|
panicln("type of +a is", t, "want", want);
|
||||||
}
|
}
|
||||||
if t := typeof(a+0); t != want {
|
if t := typeof(a+0); t != want {
|
||||||
panicln("type of a+0 is", t, "want", want);
|
panicln("type of a+0 is", t, "want", want);
|
||||||
}
|
}
|
||||||
if t := typeof(a+b); t != want {
|
|
||||||
panicln("type of a+b is", t, "want", want);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,6 @@ fixedbugs/bug049.go:6: illegal types for operand: EQ
|
|||||||
|
|
||||||
=========== fixedbugs/bug050.go
|
=========== fixedbugs/bug050.go
|
||||||
fixedbugs/bug050.go:3: package statement must be first
|
fixedbugs/bug050.go:3: package statement must be first
|
||||||
sys.6:1 fixedbugs/bug050.go:3: syntax error near package
|
|
||||||
|
|
||||||
=========== fixedbugs/bug051.go
|
=========== fixedbugs/bug051.go
|
||||||
fixedbugs/bug051.go:10: expression must be a constant
|
fixedbugs/bug051.go:10: expression must be a constant
|
||||||
|
25
test/import.go
Normal file
25
test/import.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// $G $D/$F.go
|
||||||
|
|
||||||
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// check that when import gives multiple names
|
||||||
|
// to a type, they're still all the same type
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import _os_ "os"
|
||||||
|
import "os"
|
||||||
|
import . "os"
|
||||||
|
|
||||||
|
func f(e os.Error)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var _e_ _os_.Error;
|
||||||
|
var dot Error;
|
||||||
|
|
||||||
|
f(_e_);
|
||||||
|
f(dot);
|
||||||
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ const Value = 1e12
|
|||||||
type Inter interface { M() int64 }
|
type Inter interface { M() int64 }
|
||||||
|
|
||||||
type T int64
|
type T int64
|
||||||
func (t T) M() int64 { return t }
|
func (t T) M() int64 { return int64(t) }
|
||||||
var t = T(Value)
|
var t = T(Value)
|
||||||
var pt = &t
|
var pt = &t
|
||||||
var ti Inter = t
|
var ti Inter = t
|
||||||
|
@ -450,7 +450,7 @@ func (p *parser) parseFormat() Format {
|
|||||||
type formatError string
|
type formatError string
|
||||||
|
|
||||||
func (p formatError) String() string {
|
func (p formatError) String() string {
|
||||||
return p;
|
return string(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user