Skip to content

checker: fix anon struct init with const fields(fix #20452) - #20463

Merged
spytheman merged 2 commits into
vlang:masterfrom
shove70:patch-1
Jan 11, 2024
Merged

spytheman merged 2 commits into
vlang:masterfrom
shove70:patch-1

Conversation

@shove70

@shove70 shove70 commented Jan 10, 2024

Copy link
Copy Markdown
Contributor
  1. Fixed consts not recognized in anonymous structs #20452
  2. Add tests.
module main

const salutation = 'Good morning!'

fn greeting(args struct {
		name string
		salut string = salutation
	}) string {
	return 'Hi, ${args.name}! ${args.salut}'
}

fn main() {
	println(greeting(name: 'Flibby'))
}

outputs:

Hi, Flibby! Good morning!

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman
spytheman merged commit 29d662f into vlang:master Jan 11, 2024
@shove70
shove70 deleted the patch-1 branch January 11, 2024 19:32
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.

consts not recognized in anonymous structs

2 participants