提交 6b88c184 编写于 作者: chai2010's avatar chai2010

补充类型断言失败的例子

上级 c13d6105
# 版权 @2021 凹语言 作者。保留所有权利。
// 版权 @2021 凹语言 作者。保留所有权利。
var s = []int{1, 2, 3, 4, 5, 6}
func main() {
......
# 版权 @2021 凹语言 作者。保留所有权利。
// 版权 @2021 凹语言 作者。保留所有权利。
type T1 struct {
a: i32
......
// 版权 @2023 凹语言 作者。保留所有权利。
func main() {
println("a:", 42)
str := "hello"
......
// 版权 @2021 凹语言 作者。保留所有权利。
// 版权 @2023 凹语言 作者。保留所有权利。
var Info: struct{
name: string
......
run:
go run ../main.go type-assert-01.wa
ssa:
go run ../main.go ssa type-assert-01.wa
clean:
# 凹语言自身测试(语言开发者使用)
\ No newline at end of file
// 版权 @2023 凹语言 作者。保留所有权利。
func main {
var err: myIface = &errorString{"myError"}
xerr, ok := err.(myIface)
println("ok:", ok) // BUG: OK 始终返回 false
println("xerr:", xerr)
}
type myIface interface {
MyError() => string
}
type errorString struct {
s: string
}
func errorString.MyError => string {
return this.s
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册