You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "ayush00git (via GitHub)" <gi...@apache.org> on 2026/04/21 13:18:18 UTC
[PR] fix(dart): use BigInt for proper dart web truncation [fory]
ayush00git opened a new pull request, #3600:
URL: https://github.com/apache/fory/pull/3600
<!--
**Thanks for contributing to Apache Fory™.**
**If this is your first time opening a PR on fory, you can refer to [CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory™** community has requirements on the naming of pr titles. You can also find instructions in [CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Apache Fory™ has a strong focus on performance. If the PR you submit will have an impact on performance, please benchmark it first and provide the benchmark result here.
-->
## Why?
<!-- Describe the purpose of this PR. -->
## What does this PR do?
<!-- Describe the details of this PR. -->
## Related issues
<!--
Is there any related issue? If this PR closes them you say say fix/closes:
- #xxxx0
- #xxxx1
- Fixes #xxxx2
-->
## AI Contribution Checklist
<!-- Full requirements and disclosure template:
https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs -->
- [ ] Substantial AI assistance was used in this PR: `yes` / `no`
- [ ] If `yes`, I included a completed [AI Contribution Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs) in this PR description and the required `AI Usage Disclosure`.
- [ ] If `yes`, my PR description includes the required `ai_review` summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.
<!-- If substantial AI assistance = `yes`, paste the completed checklist and disclosure block here, including the final ai_review summary and screenshot evidence from both fresh reviewers on the current PR diff or current HEAD after the latest code changes. -->
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an issue](https://github.com/apache/fory/issues/new/choose) describing the need to do so and update the document if necessary.
Delete section if not applicable.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the PR will have an impact on performance, you can submit the PR first, and if it will have impact on performance, the code reviewer will explain it), be sure to attach a benchmark data here.
Delete section if not applicable.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294678864
Such fix is not useful, the dart web support is a big work. Either support it fully, or don't support it.
The dart int will compiled to javascript numer, which is double, int64 can't be expressed using double. and if we use bigint, it's too slow and we paid cost for dart native ,which is unnecessary.
So, we should not add any half dart web fix until we have a good design that can address both issues
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed pull request #3600: fix(dart): use BigInt for proper dart web truncation
URL: https://github.com/apache/fory/pull/3600
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4293311152
The tests won't run actually, coudl you add `dart test -p chrome` to ci.yaml?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294323288
> No, that still doesn't fory dart on web work. It's just avoid real issue.
@chaokunyang making `dart test -p chrome` fully pass on `buffer_test.dart` requires a larger fix that is adding BigInt-based fallbacks to the raw 64-bit read/write methods in `buffer.dart` and `generated_support.dart`, plus rewriting the affected test literals.
Should I keep the scope of current PR only for the `writeVarInt64` fix, and for this bug open an issue and then start working on it in a new PR ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294483473
Need a full fix, but that's a big work, and break existing fory dart object model.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294520093
> Need a full fix, but that's a big work, and break existing fory dart object model.
so how should I proceed ? Should I propose a proper fix in a github issue first ? and then begin with the PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4290629052
> Could you add a test to cover it, and is there any code example to reproduce it?
@chaokunyang this may reproduce the bug and also show the verification of the fix
```dart
void main() {
const value = 3000000000; // positive, fits in JS safe-integer range
// Old (buggy) web fallback — value >> 63 is evaluated as a 32-bit int:
// 3000000000 as int32 == -1294967296 (bit 31 set → negative)
// -1294967296 >> 63 == -1 (fills with sign bit)
final buggyZigZag = (BigInt.from(value) << 1) ^ BigInt.from(value >> 63);
print(buggyZigZag); // Web: large negative number — CORRUPT
// Native: 6000000000 — correct (native >> is 64-bit)
// Fixed path — shift the BigInt, no truncation:
final signed = BigInt.from(value);
final fixedZigZag = (signed << 1) ^ (signed >> 63);
print(fixedZigZag); // Always: 6000000000 — correct on both platforms
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294812564
@chaokunyang we surely need a good design, the `float16.double` and `bfloat16.double` methods crashes as well.
```bash
UnsupportedError: Uint64 accessor not supported by dart2js.
```
do we have any plans to implement dart web in future?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294334139
for now we could add
```dart
@TestOn('vm')
library;
```
for just passing the ci checks ? or should I fix everything in this PR only ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4293639390
> @chaokunyang the new ci script exposed more failing tests in the `packages/fory/test` file. dart2js compiles the entire file. the only reliable solution is to split the web-unsafe tests into a separate file, or annotate each test body to skip the literals on web. The cleanest path would be to put the web regression test in its own separate file. should I do that ?
No, that still doesn't fory dart on web work. It's just avoid real issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4290369451
Could you add a test to cover it, and is there any code example to reproduce it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4293533833
> The tests won't run actually, coudl you add `dart test -p chrome` to ci.yaml?
my bad, let me update ci.yml
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4293593397
@chaokunyang the new ci script exposed more failing tests in the `packages/fory/test` file. dart2js compiles the entire file. the only reliable solution is to split the web-unsafe tests into a separate file, or annotate each test body to skip the literals on web.
The cleanest path would be to put the web regression test in its own separate file. should I do that ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4293820181
Dart web is a complex work, either we support it fully, or we don't support it currently. Half work is not acceptable
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] fix(dart): use BigInt for proper dart web truncation [fory]
Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on PR #3600:
URL: https://github.com/apache/fory/pull/3600#issuecomment-4294784254
> Such fix is not useful, the dart web support is a big work. Either support it fully, or don't support it.
>
> The dart int will be compiled to javascript numer, which is double, int64 can't be expressed using double. and if we use bigint, it's too slow and we paid cost for dart native ,which is unnecessary.
>
> So, we should not add any half dart web fix until we have a good design that can address both issues
fair enough, so let's keep dart web support as a future feature and you can close this PR then. as i'm free i'll look into a design which could address both these issues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org