Skip to content

Commit

Permalink
docs: gno does not support shadowing native types (#1711)
Browse files Browse the repository at this point in the history
closes #1091 

This is a simple documentation update to clarify that gno does not
support shadowing native types. I've discussed with @jaekwon and this is
not something we want to support.

---------

Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
  • Loading branch information
deelawn and leohhhn committed Mar 20, 2024
1 parent ffc7eb8 commit 7596f42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions docs/reference/go-gno-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ id: go-gno-compatibility

# Go - Gno compatibility

## Native keywords
## Reserved keywords

| keyword | support |
|-------------|------------------------|
Expand Down Expand Up @@ -34,7 +34,14 @@ id: go-gno-compatibility

Generics are currently not implemented.

## Native types
Note that Gno does not support shadowing of built-in types.
While the following built-in typecasting assignment would work in Go, this is not supported in Gno.

```go
rune := rune('a')
```

## Builtin types

| type | usage | persistency |
|-----------------------------------------------|------------------------|------------------------------------------------------------|
Expand All @@ -57,7 +64,7 @@ Generics are currently not implemented.

**\*:** depends on `T`/`T1`/`T2`

Additional native types:
Additional builtin types:

| type | comment |
|----------|--------------------------------------------------------------------------------------------|
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3282,7 +3282,7 @@ func fillNameExprPath(last BlockNode, nx *NameExpr, isDefineLHS bool) {
} else {
path = last.GetPathForName(nil, nx.Name)
if path.Type != VPBlock {
panic("expected block value path type")
panic("expected block value path type; check this is not shadowing a builtin type")
}
break
}
Expand Down

0 comments on commit 7596f42

Please sign in to comment.