-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
complex numeric type (like vec2, vec3) is warned when negate operator overriding #3416
Comments
Assuming it's dart2js and not the VM as the description says compiler... halakshin, could you provide a full self-contained coherent code sample and attach it? Added Area-Dart2JS, NeedsInfo labels. |
This comment was originally written by jjinux...@google.com I ran into this too. If you type this into Dart editor: class Vector { main() { You'll get this warning: operator 'negate' should return numeric type I think you should be able to negate things like vectors. |
This comment was originally written by domi...@google.com See also http://github.com/johnmccutchan/DartVectorMath which gets warnings from analyzer on operator negate() on quat, mat* and vec*. |
This comment was originally written by @financecoding Looking at the dart spec, the static analyzer should be correct for providing warnings. Why this is a warning is something I might not fully understand. http://goo.gl/hK8ix |
This comment was originally written by @financecoding Rereading the spec [...] |
This sounds like a specification issue to me. We do not "force" other arithmetic operators to return numeric types, so I don't think we should force the unary negate operator to do so. Is this a known issue, Gilad? Set owner to @gbracha. |
Added Done label. |
…native, protobuf, pub_semver, shelf, stack_trace, tools, vector_math, webdev Revisions updated by `dart tools/rev_sdk_deps.dart`. args (https://github.com/dart-lang/args/compare/f0f6cd2..a9543c0): a9543c0 2023-05-31 Devon Carew switch to using package:dart_flutter_team_lints (#247) 36407ea 2023-05-31 Devon Carew adjust the validation of mandatory options (#246) bazel_worker (https://github.com/dart-lang/bazel_worker/compare/d9b389f..c14a268): c14a268 2023-05-31 Kevin Moore Bump lints, regenerate proto file, fix script (#74) dartdoc (https://github.com/dart-lang/dartdoc/compare/950898f..39fe1a8): 39fe1a8a 2023-05-31 Parker Lougheed Update highlight.js to 11.8.0 for Dart 3 syntax highlighting (#3416) 4574e819 2023-05-30 Sam Rawlins Convert kind to an enum (#3426) http (https://github.com/dart-lang/http/compare/18a43a2..8834aec): 8834aec 2023-05-31 Brian Quinlan Update readme and prepare for a new release (#954) aca7f0e 2023-05-31 dependabot[bot] Bump futureware-tech/simulator-action from 1 to 2 (#936) 7a238a9 2023-05-31 dependabot[bot] Bump actions/labeler from 4.0.2 to 4.0.4 (#952) 4c0eb48 2023-05-30 Brian Quinlan Prepare to publish cupertino_http 1.0.0 (#951) leak_tracker (https://github.com/dart-lang/leak_tracker/compare/7f2cab3..cbbdeca): cbbdeca 2023-05-31 Polina Cherkasova Improve getting retaining path. (#69) mockito (https://github.com/dart-lang/mockito/compare/40fe2ca..924f65c): 924f65c 2023-06-01 Ilya Yanok Add support for records native (https://github.com/dart-lang/native/compare/76bc55e..c851e69): c851e69 2023-06-01 dependabot[bot] Bump nttld/setup-ndk (#57) 0df0cad 2023-06-01 dependabot[bot] Bump actions/labeler from 4.0.3 to 4.0.4 (#58) c30faa2 2023-05-31 Daco Harkes [c_compiler] test install_name_tool behavior (#56) 45ef2e7 2023-05-31 Daco Harkes [c_compiler] Support setting the install name of dylibs (#55) protobuf (https://github.com/dart-lang/protobuf/compare/346a72d..da6953c): da6953c 2023-05-31 Kevin Moore Update to latest lints and Dart SDK (#828) pub_semver (https://github.com/dart-lang/pub_semver/compare/c034352..3930557): 3930557 2023-05-31 Kevin Moore Bump lints, require Dart 3.0 (#89) shelf (https://github.com/dart-lang/shelf/compare/a404b6a..ce379aa): ce379aa 2023-06-01 dependabot[bot] Bump actions/labeler from 4.0.3 to 4.0.4 (#363) stack_trace (https://github.com/dart-lang/stack_trace/compare/86f7e30..8b2046e): 8b2046e 2023-05-31 Devon Carew blast_repo fixes (#134) tools (https://github.com/dart-lang/tools/compare/d723a55..389925f): 389925f 2023-06-01 Elias Yishak Utility function added to check permissions on directory (#95) a436fee 2023-05-31 Elias Yishak Asserts added to check all relevant GA4 limitations (#96) vector_math (https://github.com/google/vector_math.dart/compare/cd87f57..a3aca09): a3aca09 2023-05-31 Lukas Klingsbo fix: Revert negation change for Vector2 (#296) webdev (https://github.com/dart-lang/webdev/compare/d442fa8..f565d7f): f565d7f1 2023-05-31 Anna Gringauze Disable flaky test on windows (#2127) 6eed300e 2023-05-31 Anna Gringauze Cleanup expression evalaluation tests (#2125) Change-Id: Ia568db23bbc923f764cdf323e249175b609d57ee Tested: affected files are regenerated test goldens Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306903 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Auto-Submit: Devon Carew <devoncarew@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This issue was originally filed by halak...@gmail.com
What steps will reproduce the problem?
class vec2 { num x; num y; vec2(this.x, this.y); }
class vec2 { ... vec2 operator negate() { return new vec2(-x, -y); } }
What is the expected output? What do you see instead?
no compiler warning
What version of the product are you using? On what operating system?
Windows7
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: