Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checker: disallow directly indexing sumtype and interface, when using as parameters(fix #19811) #19982

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

shove70
Copy link
Contributor

@shove70 shove70 commented Nov 24, 2023

  1. Fixed type Tree =string | map[string]string confuse v  #19811
  2. Add tests.
type Tree = string| map[string]string

fn append(mut tree Tree) {
    print(tree["key"])
}

fn main() {
}

outputs:

a.v:4:15: error: type `Tree` does not support indexing
    2 | 
    3 | fn append(mut tree Tree) {
    4 |     print(tree["key"])
      |               ~~~~~~~
    5 | }
    6 |

@spytheman spytheman merged commit febd54b into vlang:master Nov 24, 2023
54 checks passed
@shove70 shove70 deleted the sumtype_index branch November 25, 2023 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

type Tree =string | map[string]string confuse v
2 participants