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

duplicate entries in map (and possibly slice/array) decls don't throw an error #758

Closed
thehowl opened this issue Apr 19, 2023 · 2 comments · Fixed by #786
Closed

duplicate entries in map (and possibly slice/array) decls don't throw an error #758

thehowl opened this issue Apr 19, 2023 · 2 comments · Fixed by #786

Comments

@thehowl
Copy link
Member

thehowl commented Apr 19, 2023

See #708

	m := map[string][]Foo{
		"hello": {Foo{"foo"}, Foo{"bar"}},
		"world": {Foo{"truc"}, Foo{"machin"}},
		"hello": {},
	}

Does not error in parsing/execution. My suspect is that this doesn't happen in array/slice declaration either (ie. []string{0: "a", 10: "b", 10: "c"}

@tbruyelle
Copy link
Contributor

[]string{0: "a", 10: "b", 10: "c"}

I was wondering why you were also mentioning slices for this bug: I didn't know it was possible to create a slice like that! 😮

tbruyelle added a commit to tbruyelle/gno that referenced this issue Apr 20, 2023
related to gnolang#758

If you manage to solve this challenge by updating the gnovm code, move
those files into the `gnovm/test/files` folder (eventually increment the
number suffix in the name according to existing files).
tbruyelle added a commit to tbruyelle/gno that referenced this issue Apr 20, 2023
- Add 2 challenges for map and slice literals, as described in gnolang#758
- Add a challenge to handle chained panics, as described in gnolang#756
- Add a challenge to handle a specific rule of recover, as described in
  this [comment][0]

If you manage to solve one of these challenges by updating the gnovm code, move
those files into the `gnovm/test/files` folder (eventually increment the
number suffix in the name according to existing files).

[0]: gnolang#756 (comment)
tbruyelle added a commit to tbruyelle/gno that referenced this issue Apr 20, 2023
- Add 2 challenges for map and slice literals, as described in gnolang#758
- Add a challenge to handle chained panics, as described in gnolang#756
- Add a challenge to handle a specific rule of recover, as described in
  this [comment][0]

If you manage to solve one of these challenges by updating the gnovm code, move
those files into the `gnovm/test/files` folder (eventually increment the
number suffix in the name according to existing files).

[0]: gnolang#756 (comment)
tbruyelle added a commit to tbruyelle/gno that referenced this issue Apr 20, 2023
- Add 2 challenges for map and slice literals, as described in gnolang#758
- Add a challenge to handle chained panics, as described in gnolang#756
- Add a challenge to handle a specific rule of recover, as described in
  this [comment][0]

Also add some working recover cases in `tests/files`, to increase code
coverage.

If you manage to solve one of these challenges by updating the gnovm code, move
those files into the `gnovm/test/files` folder (eventually increment the
number suffix in the name according to existing files).

[0]: gnolang#756 (comment)
@thehowl
Copy link
Member Author

thehowl commented Apr 20, 2023

@tbruyelle the most common use I've found in the wild is to create "cheap" maps of ie. forbidden characters and similar.

var forbidden = [256]bool{
    '$': true,
    '%': true,
    '-': true,
}

the remaining will be initialized to false as a zero value :)

tbruyelle added a commit to tbruyelle/gno that referenced this issue Apr 27, 2023
Fix gnolang#758

Also enrich tests/files with more cases of map, slice and arrau
literals.
thehowl pushed a commit that referenced this issue May 17, 2023
Fix #758

Also enrich tests/files with more cases of map, slice and array
literals.
moul-bot pushed a commit that referenced this issue May 19, 2023
Fix #758

Also enrich tests/files with more cases of map, slice and array
literals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants