-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix off-by-one error in cxx codegen #36574
Conversation
This pull request was exported from Phabricator. Differential Revision: D44299193 |
Base commit: 4a15f90 |
This pull request was exported from Phabricator. Differential Revision: D44299193 |
Summary: Pull Request resolved: facebook#36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: 41a41719f8bb9812269277ae13c9a952ed3b2f35
dc76b42
to
c23d49f
Compare
This pull request was exported from Phabricator. Differential Revision: D44299193 |
Summary: Pull Request resolved: facebook#36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: 11d51dd25a99f276b74fa4271cb5a46a136eac19
c23d49f
to
87164ab
Compare
Summary: Pull Request resolved: facebook#36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: d109eea807966c2fd6b08f0a56d30ea10f1320c5
This pull request was exported from Phabricator. Differential Revision: D44299193 |
87164ab
to
885c17c
Compare
Summary: Pull Request resolved: facebook#36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: c08ac30666c5476eb41b435fa8a456a9851e77d6
This pull request was exported from Phabricator. Differential Revision: D44299193 |
885c17c
to
d18f823
Compare
This pull request has been merged in 0a8164d. |
Summary: Pull Request resolved: facebook#36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: f00b9f5e09c2f524f9393137346c256d8b6b2979
Summary: Pull Request resolved: facebook#36574 We would previously generate the following codegen for optional args ``` return static_cast<NativeAudioModuleCxxSpecJSI *>(&turboModule)->playAudio( rt, args[0].asString(rt), args[1].isNull() || args[1].isUndefined() ? std::nullopt : std::make_optional(args[1].asString(rt)), args[2].isNull() || args[2].isUndefined() ? std::nullopt : std::make_optional(args[2].asString(rt)), args[3].asNumber(), count < 4 || args[4].isNull() || args[4].isUndefined() ? std::nullopt : std::make_optional(args[4].asObject(rt)), count < 5 || args[5].isNull() || args[5].isUndefined() ? std::nullopt : std::make_optional(args[5].asObject(rt)), count < 6 || args[6].isNull() || args[6].isUndefined() ? std::nullopt : std::make_optional(args[6].asBool()) ); ``` However, the counts checked are off-by-one, causing us to incorrectly process args. Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args Differential Revision: D44299193 fbshipit-source-id: f00b9f5e09c2f524f9393137346c256d8b6b2979
Summary:
We would previously generate the following codegen for optional args
However, the counts checked are off-by-one, causing us to incorrectly process args.
Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional args
Differential Revision: D44299193