`Rect::containsPoint` is not `const`, so a `const Rect` cannot be asked whether it holds a point
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Đọc packages/react-native/ReactCommon/react/renderer/graphics/Rect.h, đặc biệt là khai báo containsPoint ở các dòng 70–74, rồi so sánh với các accessor lân cận được định tính const. Mã tái hiện probe/const-frame.cpp cho thấy lời gọi bị lỗi; hãy biên dịch nó bằng lệnh trong issue để xác nhận bản sửa. Hoàn tất khi probe đó biên dịch được với containsPoint được gọi trên một const Rect &.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
facebook::react::Rect::containsPoint(Point) (Rect.h L70-L74) only reads origin and size, yet it is the one reading member of Rect not marked const: getMaxX(), getMidY(), getCenter() and the others beside it are const noexcept. Code holding a const Rect &, such as a frame kept in a const record or passed as a const reference, cannot call it and has to copy the rectangle first. I met this in a C++ touch handler that asks each region's const frame whether it holds the touch's point.
Steps to reproduce
- Clone the reproducer and run
bash ./reproduce.sh. It installsReproducerApp's dependencies and compilesprobe/const-frame.cpp, which callscontainsPointon aconst Rect &, with-fsyntax-onlyagainst thatreact-nativepackage'sReactCommon. It exits 1 while the call does not compile, 0 once it does. - Or by hand, after
yarn installinReproducerApp:clang++ -std=c++20 -fsyntax-only -I ReproducerApp/node_modules/react-native/ReactCommon -I ReproducerApp/node_modules/react-native/ReactCommon/react/renderer/graphics/platform/cxx probe/const-frame.cpp
Expected: the probe compiles.
Seen: error: 'this' argument to member function 'containsPoint' has type 'const facebook::react::Rect', but function is not marked const.
React Native Version
0.90.0-nightly-20261127-7a2d1d257
Affected Platforms
Runtime - Android, Runtime - iOS
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: Windows 11 10.0.26300
CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor "
Memory: 124.53 GB / 255.67 GB
Binaries:
Node:
version: 26.12.1
path: C:\Program Files\nodejs\node.EXE
Yarn:
version: 1.22.22
path: C:\Users\<user>\AppData\Roaming\npm\yarn.CMD
npm:
version: 12.2.1
path: C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK: Not Found
Windows SDK:
AllowDevelopmentWithoutDevLicense: Enabled
Versions:
- 10.0.19041.0
- 10.0.26100.0
IDEs:
Android Studio: AI-262.9437.185.2621.16467767
Visual Studio: Not Found
Languages:
Java:
version: 17.0.20.1
path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
Ruby: Not Found
npmPackages:
"@react-native-community/cli":
installed: 22.0.0-alpha.0
wanted: 22.0.0-alpha.0
react:
installed: 19.3.0
wanted: 19.3.0
react-native:
installed: 0.90.0-nightly-20261127-7a2d1d257
wanted: 0.90.0-nightly-20261127-7a2d1d257
react-native-windows: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: Not found
newArchEnabled: Not found
Stacktrace or Logs
react-native 0.90.0-nightly-20261127-7a2d1d257, clang version 23.1.4 (https://github.com/llvm/llvm-project 7a941dfb2877a0b8cf30323fefa85ad019e0b0f5)
#include <react/renderer/graphics/Rect.h>
auto holds(const facebook::react::Rect &frame, facebook::react::Point point) -> bool {
return frame.containsPoint(point);
}
probe/const-frame.cpp:4:10: error: 'this' argument to member function 'containsPoint' has type 'const facebook::react::Rect', but function is not marked const
4 | return frame.containsPoint(point);
| ^~~~~
ReproducerApp/node_modules/react-native/ReactCommon\react/renderer/graphics/Rect.h:70:8: note: 'containsPoint' declared here
70 | bool containsPoint(Point point) noexcept
| ^
1 error generated.
RESULT: containsPoint is not const, so a const Rect cannot call it; exit 1
MANDATORY Reproducer
https://github.com/YevheniiKotyrlo/rn-rect-contains-point-const
Screenshots and Videos
No response
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.4k
- Merge trung bình
- 3 ngày 5 phút
- Pull request đã merge (30 ngày)
- 328
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của react/react-native
-
Needs: Triage :mag: Platform: Android
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
react/react-native#60177 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Needs: Author Feedback Needs: Repro
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
react/react-native#60091 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ReactNative-application.cmake links autolinked libraries to common_flags with the plain target_link_libraries signature, so a library that uses PRIVATE fails the app's CMake configureCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởNeeds: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
react/react-native#60000 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
iOS Fabric pointer-handler reset leaves the next lone touch non-primaryCó thể đã có người làm @alleneubank đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
react/react-native#59919 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
react/react-native#59722 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của react/react-native
Issue tương tự
-
difficulty:easy func:python os:windows prio:high type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NatronGitHub/Natron#2029 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ardazishvili/Sota#114 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
need triaging
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày