dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.26k stars 1.58k forks source link

`Pointer.fromFunction`'s exceptional return const detection doesn't work very well #57115

Open liamappelbe opened 4 hours ago

liamappelbe commented 4 hours ago

A user reported some bugs with Pointer.fromFunction's exceptional return param: https://github.com/dart-lang/native/issues/1724

There are a few different bugs here, but they're all to do with the const detection. The following all erroneously produce a "Exceptional return value must be a constant" error when passed to exceptional return:

dart-github-bot commented 4 hours ago

Summary: Pointer.fromFunction incorrectly flags negative integers, enums, and enhanced enum values as non-constant when used with exceptional return parameters. Const detection needs improvement.