Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
flatbuffers
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
flatbuffers
Commits
90441c20
Commit
90441c20
authored
Apr 15, 2019
by
Nils Berg
Committed by
Wouter van Oortmerssen
Apr 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix check for Enum defaults (#5292)
fixes #5288
parent
cef8f928
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
1 deletion
+2
-1
idl_parser.cpp
src/idl_parser.cpp
+1
-1
test.cpp
tests/test.cpp
+1
-0
No files found.
src/idl_parser.cpp
View file @
90441c20
...
...
@@ -670,11 +670,11 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
if
(
token_
==
'='
)
{
NEXT
();
ECHECK
(
ParseSingleValue
(
&
field
->
name
,
field
->
value
,
true
));
if
(
!
IsScalar
(
type
.
base_type
)
||
(
struct_def
.
fixed
&&
field
->
value
.
constant
!=
"0"
))
return
Error
(
"default values currently only supported for scalars in tables"
);
ECHECK
(
ParseSingleValue
(
&
field
->
name
,
field
->
value
,
true
));
}
if
(
type
.
enum_def
&&
!
type
.
enum_def
->
is_union
&&
...
...
tests/test.cpp
View file @
90441c20
...
...
@@ -1275,6 +1275,7 @@ void ErrorTest() {
TestError
(
"table Y {} table X { Y:int; }"
,
"same as table"
);
TestError
(
"struct X { Y:string; }"
,
"only scalar"
);
TestError
(
"table X { Y:string =
\"\"
; }"
,
"default values"
);
TestError
(
"struct X { a:uint = 42; }"
,
"default values"
);
TestError
(
"enum Y:byte { Z = 1 } table X { y:Y; }"
,
"not part of enum"
);
TestError
(
"struct X { Y:int (deprecated); }"
,
"deprecate"
);
TestError
(
"union Z { X } table X { Y:Z; } root_type X; { Y: {}, A:1 }"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment