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
Bitwise: Fix overflow from Vim 8.0.0219 #481
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
テスト通ったらマージします!
test/Bitwise.vimspec
Outdated
@@ -1,6 +1,11 @@ | |||
Describe Bitwise | |||
Before all | |||
let B = vital#vital#new().import('Bitwise') | |||
" NOTE: | |||
" A int literal larger than or equal to 0x8000000000000000 will be rounded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An
test/Bitwise.vimspec
Outdated
@@ -1,6 +1,11 @@ | |||
Describe Bitwise | |||
Before all | |||
let B = vital#vital#new().import('Bitwise') | |||
" NOTE: | |||
" A int literal larger than or equal to 0x8000000000000000 will be rounded | |||
" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219 so create it without literal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/so/, so/
test/Bitwise.vimspec
Outdated
@@ -227,14 +232,20 @@ Describe Bitwise | |||
if has('num64') | |||
Context with 64bit number | |||
It applies sign extension | |||
" NOTE: | |||
" A int literal larger than or equal to 0x8000000000000000 will be rounded | |||
" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219 so create it without literal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same)
Vim 8.0.0219 change the behavior of overflow and now any literal larger than or equal to 0x8000000000000000 will be rounded to 0x7FFFFFFFFFFFFFFF. To fix this problem, create values without using literal in code and tests.
テスト完了後にマージします |
" to 0x7FFFFFFFFFFFFFFF after Vim 8.0.0219, so create it without literal | ||
let s:xFFFFFFFF00000000 = has('patch-8.0.0219') | ||
\ ? 0xFFFFFFFF * s:pow2[and(32, s:mask)] | ||
\ : 0xFFFFFFFF00000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここの条件分岐は必要?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要ですが
- 以前動いていた部分を変更する必要がない
- 変数名でわかりやすくしているが
0xFFFFFFFF00000000
が動くならそれが正しいんだよ、ってのをコード的に表現したかった
って感じで分岐してます。関数呼び出しが一回分増えるコストがありますが、無視できるかなと
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解。
🎉 |
Vim 8.0.0219 change the behavior of overflow and now any literal
larger than or equal to 0x8000000000000000 will be rounded to
0x7FFFFFFFFFFFFFFF.
To fix this problem, create values without using literal in code and tests.
#479
こんなんでどうでしょう?