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: check error for match conditions with parenthesis (fix #13121) #13130

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jan 10, 2022

This PR check error for match conditions with parenthesis (fix #13121).

  • Check error for match conditions with parenthesis.
  • Add test.
module main

enum Enum {
	a
	b
	c
}

fn foo() ?Enum {
	return .a
}

fn bar() bool {
	return match (foo()) {
		.a { true }
		.b, .c { false }
	}
}

fn main() {
	bar()
}

PS D:\Test\v\tt1> v run .
.\tt1.v:14:15: error: unnecessary `()` in `match` condition, use `match expr {` instead of `match (expr) {`.
   12 |
   13 | fn bar() bool {
   14 |     return match (foo()) {
      |                  ~~~~~~~
   15 |         .a { true }
   16 |         .b, .c { false }

@spytheman spytheman merged commit 791972e into vlang:master Jan 11, 2022
spytheman added a commit to jeffmikels/v that referenced this pull request Jan 11, 2022
* origin:
  ci: vfmt fmt.v ...
  cgen: fix `$if T.typ is Type {` (vlang#13135)
  parser: add support for mutable if guards (vlang#13132)
  tests: test with valgrind rune.bytes(), fix leak in .str_escaped()
  builtin: reduce allocations in `rune.bytes()`
  builtin: allow msvc users to link against a custom compiled Boehm library (vlang#13133)
  cgen: fix cast in the index of reference fixed array (fix vlang#13128) (vlang#13131)
  builtin: add a rune.bytes() convenience method (vlang#13129)
  checker: check error for match conditions with parenthesis (vlang#13130)
@yuyi98 yuyi98 deleted the check_parentheses_of_match branch January 11, 2022 22:43
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.

Parantesis skip option error check
2 participants