[fidl] Ensure that visitors visit type ctors for errors
This was causing errors with types with more than one token to get
swallowed during formatting.
Change-Id: I23371f9e9ec273e879760b0f8476d7f82aee4498
diff --git a/zircon/system/host/fidl/lib/raw_ast.cpp b/zircon/system/host/fidl/lib/raw_ast.cpp
index a02b268..39578e7 100644
--- a/zircon/system/host/fidl/lib/raw_ast.cpp
+++ b/zircon/system/host/fidl/lib/raw_ast.cpp
@@ -179,6 +179,9 @@
if (maybe_response != nullptr) {
visitor.OnParameterList(maybe_response);
}
+ if (maybe_error_ctor != nullptr) {
+ visitor.OnTypeConstructor(maybe_error_ctor);
+ }
}
void ComposeProtocol::Accept(TreeVisitor& visitor) {
diff --git a/zircon/system/utest/fidl-compiler/BUILD.gn b/zircon/system/utest/fidl-compiler/BUILD.gn
index dab67f3..defb973 100644
--- a/zircon/system/utest/fidl-compiler/BUILD.gn
+++ b/zircon/system/utest/fidl-compiler/BUILD.gn
@@ -37,7 +37,7 @@
"$examples_dir/types.fidl",
"testdata/badformat.fidl.noformat",
"testdata/doc_comments.fidl",
- "testdata/goodformat.fidl",
+ "testdata/goodformat.test.fidl",
]
script = "gen-examples.sh"
args = rebase_path(outputs, root_build_dir) +
diff --git a/zircon/system/utest/fidl-compiler/formatter_tests.cpp b/zircon/system/utest/fidl-compiler/formatter_tests.cpp
index fc5cb11..2fc0ef4 100644
--- a/zircon/system/utest/fidl-compiler/formatter_tests.cpp
+++ b/zircon/system/utest/fidl-compiler/formatter_tests.cpp
@@ -113,7 +113,7 @@
std::string formatted_bad_output;
for (auto element : Examples::map()) {
- if (element.first.find("testdata/goodformat.fidl") != std::string::npos) {
+ if (element.first.find("testdata/goodformat.test.fidl") != std::string::npos) {
good_output = Examples::map()[element.first];
} else if (element.first.find("testdata/badformat.fidl") != std::string::npos) {
formatted_bad_output = formatted_output_[element.first];
diff --git a/zircon/system/utest/fidl-compiler/testdata/badformat.fidl.noformat b/zircon/system/utest/fidl-compiler/testdata/badformat.fidl.noformat
index bb88c08..93a96e0 100644
--- a/zircon/system/utest/fidl-compiler/testdata/badformat.fidl.noformat
+++ b/zircon/system/utest/fidl-compiler/testdata/badformat.fidl.noformat
@@ -127,6 +127,12 @@
MethodWithAnError() -> ( int32 a ) error uint32
;
+ // and now, for something completely different.
+ // the error syntax.
+ MethodWithAZxError() -> ( int32 a ) error zx.status;
+
+ MethodWithAZxErrorNoReturn() -> ( ) error zx.status;
+
}
diff --git a/zircon/system/utest/fidl-compiler/testdata/goodformat.fidl b/zircon/system/utest/fidl-compiler/testdata/goodformat.test.fidl
similarity index 93%
rename from zircon/system/utest/fidl-compiler/testdata/goodformat.fidl
rename to zircon/system/utest/fidl-compiler/testdata/goodformat.test.fidl
index 31c2bb4..a1ac953 100644
--- a/zircon/system/utest/fidl-compiler/testdata/goodformat.fidl
+++ b/zircon/system/utest/fidl-compiler/testdata/goodformat.test.fidl
@@ -131,6 +131,12 @@
// and now, the error syntax
MethodWithAnError() -> (int32 a) error uint32;
+
+ // and now, for something completely different.
+ // the error syntax.
+ MethodWithAZxError() -> (int32 a) error zx.status;
+
+ MethodWithAZxErrorNoReturn() -> () error zx.status;
};
// following example pulled from sample FIDL library