Skip to content

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

Merged
spytheman merged 1 commit into
vlang:masterfrom
shove70:sumtype_index
Nov 24, 2023
Merged

spytheman merged 1 commit into
vlang:masterfrom
shove70:sumtype_index

Conversation

@shove70

@shove70 shove70 commented Nov 24, 2023

Copy link
Copy Markdown
Contributor
  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 |

Comment thread vlib/v/checker/tests/index_sumtype_or_interface_params_err.vv
@spytheman
spytheman merged commit febd54b into vlang:master Nov 24, 2023
@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