mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
do not allow one letter struct names
This commit is contained in:
parent
c58c03167d
commit
f14425ec18
@ -324,23 +324,21 @@ fn (g &Game) draw_field() {
|
||||
}
|
||||
|
||||
fn (g mut Game) draw_ui() {
|
||||
if g.font_loaded {WinHeight / 2 + 2 * TextSize
|
||||
if g.font_loaded {
|
||||
g.ft.draw_text(1, 2, 'score: ' + g.score.str(), text_cfg)
|
||||
if g.state == .gameover {
|
||||
g.gg.draw_rect(0, WinHeight / 2 - TextSize, WinWidth,
|
||||
5 * TextSize, UIColor)
|
||||
5 * TextSize, UIColor)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 0 * TextSize, 'Game Over', text_cfg)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'SPACE to restart', text_cfg)
|
||||
} else if g.state == .paused {
|
||||
g.gg.draw_rect(0, WinHeight / 2 - TextSize, WinWidth,
|
||||
5 * TextSize, UIColor)
|
||||
5 * TextSize, UIColor)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 0 * TextSize, 'Game Paused', text_cfg)
|
||||
g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'SPACE to resume', text_cfg)
|
||||
}
|
||||
}
|
||||
|
||||
g.gg.draw_rect(0, BlockSize, WinWidth, LimitThickness, UIColor)
|
||||
|
||||
}
|
||||
|
||||
fn (g mut Game) draw_scene() {
|
||||
|
@ -23,6 +23,7 @@ fn opt_ok(data voidptr, size int) Option {
|
||||
return res
|
||||
}
|
||||
|
||||
// used internally when returning `none`
|
||||
fn opt_none() Option {
|
||||
return Option{ is_none: true }
|
||||
}
|
||||
|
@ -684,6 +684,9 @@ fn (p mut Parser) struct_decl() {
|
||||
cat = .c_typedef
|
||||
}
|
||||
}
|
||||
if name.len == 1 && !p.pref.building_v && !p.pref.is_repl {
|
||||
p.warn('struct names must have more than one character')
|
||||
}
|
||||
if !is_c && !good_type_name(name) {
|
||||
p.error('bad struct name, e.g. use `HttpRequest` instead of `HTTPRequest`')
|
||||
}
|
||||
@ -693,11 +696,11 @@ fn (p mut Parser) struct_decl() {
|
||||
}
|
||||
mut typ := p.table.find_type(name)
|
||||
if p.pass == .decl && p.table.known_type_fast(typ) {
|
||||
if name in reserved_type_param_names {
|
||||
p.error('name `$name` is reserved for type parameters')
|
||||
} else {
|
||||
p.error('type `$name` redeclared')
|
||||
}
|
||||
//if name in reserved_type_param_names {
|
||||
//p.error('name `$name` is reserved for type parameters')
|
||||
//} else {
|
||||
p.error('type `$name` redeclared')
|
||||
//}
|
||||
}
|
||||
if is_objc {
|
||||
// Forward declaration of an Objective-C interface with `@class` :)
|
||||
|
Loading…
Reference in New Issue
Block a user