-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Compiler crash: invalid kind for first(tyObject) #7675
Comments
This works though: type
int128*{.importc: "__int128".} = object
# Size missing https://github.com/nim-lang/Nim/issues/7674
do_not_use1, do_not_use2: uint64
helper128 = object
lo, hi: uint64
func `+`(x, y: int128): int128 {.magic: "AddI".}
var
helperA = helper128(lo: 10)
helperB = helper128(lo: 30)
let
a = (cast[ptr int128](helperA.addr))[]
b = (cast[ptr int128](helperB.addr))[]
var c = a + b
echo (cast[ptr helper128](c.addr))[] # (lo: 40, hi: 0) Tagging #7674 as setting the size would probably solve this. |
Come on, these magics are not for others. :P |
Okay closing this. I can get by with emit. I'd like the size to work though. Emit: {.emit:"""
typedef unsigned __int128 NU128;
typedef __int128 NI128;
""".}
type
int128*{.importc: "NI128".} = object
# Size missing https://github.com/nim-lang/Nim/issues/7674
do_not_use1, do_not_use2: uint64
helper128 = object
lo, hi: uint64
func `+`(x, y: int128): int128 {.magic: "AddI".}
# func `shl`(x, y: int128): int128 {.magic: "ShlI".}
# # Generates c_3kT3fyGcLUlO9cGAfoG5F0w = ()((NU128)(a_H4uaduhuKIzzvSo9a5XGckw) << (NU128)(b_s7Jde6jEzqXVu63vxBEZxg));
# # Notice how the parenthesis is empty
func `shl`(x, y: int128): int128 =
{.emit: "`result` = (NI128)((NU128)(`x`) << (NU128)(`y`));".}
# Works
var
helperA = helper128(lo: 10)
helperB = helper128(lo: 3)
let
a = (cast[ptr int128](helperA.addr))[]
b = (cast[ptr int128](helperB.addr))[]
var c = a shl b
echo (cast[ptr helper128](c.addr))[] # (lo: 80, hi: 0) |
@mratsim, besides https://github.com/nim-lang/Nim/blob/devel/lib/js/jsffi.nim#L137 You can think of the |
Test case:
The text was updated successfully, but these errors were encountered: