8000 _ no longer forced for keywords as var/struct fields by JalonSolov · Pull Request #139 · vlang/go2v · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

_ no longer forced for keywords as var/struct fields #139

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

Merged
merged 1 commit into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/module/module.vv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module fn_
module fn
File renamed without changes.
File renamed without changes.
11 changes: 3 additions & 8 deletions util.v
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ fn go2v_type(typ string) string {
}

fn (mut app App) go2v_ident(ident string) string {
if ident == 'nil' {
return 'unsafe { nil }'
}
if app.force_upper || ident in app.struct_or_alias {
app.force_upper = false
if ident in v_keywords_which_are_not_go_keywords {
return ident + '_'
}
if ident in ['string', 'int', 'float64'] {
return ident
}
Expand All @@ -64,12 +64,7 @@ fn (mut app App) go2v_ident(ident string) string {
return go2v_ident2(ident)
}

const v_keywords_which_are_not_go_keywords = ['match', 'lock', 'fn', 'enum', 'in', 'as']

fn go2v_ident2(ident string) string {
x := ident.camel_to_snake() // to_lower()) // TODO ?
if x in v_keywords_which_are_not_go_keywords {
return x + '_'
}
return x
}
Loading
0