fix attributes on public structs & enums

pull/3610/head
joe-conigliaro 2020-01-30 11:27:13 +11:00 committed by GitHub
parent 6c5879add9
commit 80d936adc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 3 deletions

View File

@ -3071,17 +3071,19 @@ fn (p mut Parser) attribute() {
}
p.check(.rsbr)
p.fgen_nl()
if p.tok == .key_fn || (p.tok == .key_pub && p.peek() == .key_fn) {
is_pub := p.tok == .key_pub
peek := p.peek()
if p.tok == .key_fn || (is_pub && peek == .key_fn) {
p.fn_decl()
p.attr = ''
return
}
else if p.tok == .key_struct {
else if p.tok == .key_struct || (is_pub && peek == .key_struct) {
p.struct_decl([])
p.attr = ''
return
}
else if p.tok == .key_enum {
else if p.tok == .key_enum || (is_pub && peek == .key_enum) {
p.enum_decl(false)
p.attr = ''
return

View File

@ -0,0 +1,33 @@
[testing]
struct StructAttrTest {
foo string
bar int
}
[testing]
pub struct PubStructAttrTest {
foo string
bar int
}
[testing]
enum EnumAttrTest {
one
two
}
[testing]
pub enum PubEnumAttrTest {
one
two
}
[testing]
fn test_fn_attribte() {
assert true
}
[testing]
pub fn test_pub_fn_attribte() {
assert true
}