Skip to content

Commit

Permalink
Forbid unstructured annotations on field types
Browse files Browse the repository at this point in the history
Reviewed By: vitaut, createdbysk

Differential Revision: D67951605

fbshipit-source-id: 9eeb681f2fa688aa6c7529c37f6f1319a00d7c94
  • Loading branch information
iahs authored and facebook-github-bot committed Jan 10, 2025
1 parent f708c87 commit 081bf38
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion third-party/thrift/src/thrift/compiler/sema/sema_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class node_metadata_cache {
};

struct sema_params {
bool forbid_unstructured_annotations_on_field_types = false;
bool forbid_unstructured_annotations_on_field_types = true;
bool skip_lowering_type_annotations = false;

/**
Expand Down
2 changes: 2 additions & 0 deletions third-party/thrift/src/thrift/compiler/test/compiler_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@ TEST(CompilerTest, annotation_positions) {
}
struct Foo {
1: i32 (annot) f
# expected-error@-1: Annotations are not allowed in this position. Extract the type into a named typedef instead.
@Type{name="foo"}
2: i32 g
}
Expand Down Expand Up @@ -808,6 +809,7 @@ TEST(CompilerTest, cpp_type_compatibility) {
struct B {
@cpp.Adapter{name="Adapter"} # expected-warning: At most one of @cpp.Type/@cpp.Adapter/cpp.type/cpp.template can be specified on a definition.
1: i32 (cpp.type = "std::uint32_t") field; # expected-warning@-1: The cpp.type/cpp.template annotations are deprecated, use @cpp.Type instead
# expected-error@-2: Annotations are not allowed in this position. Extract the type into a named typedef instead.
@cpp.Adapter{name="Adapter"} # expected-warning: At most one of @cpp.Type/@cpp.Adapter/cpp.type/cpp.template can be specified on a definition.
@cpp.Type{name="std::uint32_t"}
2: i32 field2;
Expand Down

0 comments on commit 081bf38

Please sign in to comment.