-
-
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
cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
(eg: enables nimyaml at CT)
#15947
Conversation
cast
now works in VM in more contexts, behaving like in RT; eg: int <=> ptr T | ref T
cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
(eg: enables nimyaml at CT with ref types)
cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
(eg: enables nimyaml at CT with ref types)cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
(eg: nimyaml at CT)
78d0583
to
4975608
Compare
cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
(eg: nimyaml at CT)cast
now works in VM in more contexts, behaving like in RT; eg: int|pointer <=> ptr T | ref T
(eg: enables nimyaml at CT)
4975608
to
4b7f639
Compare
ping @Araq , I've rebased to fix bitrot conflicts |
else: return false | ||
of tyObject: | ||
if isAssign: | ||
let lhs = cast[PNode](address) |
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.
Wait what?
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.
It's the same as all the other pre-existing cast[ptr T](address)[]
in derefPtrToReg
, with T = TNode
in this case.
The tests exercise all of this, and make CT behavior consistent with RT behavior.
But I don't mind that nimYaml doesn't work at compile-time all that much. I care more about my compiler not crashing in mysterious ways because "everything works at compile-time". These crashes at runtime are bad enough already but at least then you have valgrind and GDB and so many tools built for it. How does the average Nim developer debug VM crashes? Previously this was the rule:
With your "improved" stuff:
|
4b7f639
to
2e30523
Compare
PTAL, all code comments addressed.
It's not just nimYaml. It's all the Users shouldn't have to be forced into workarounds involving using
|
But it is. At runtime you have tools to mitigate the problems of the lack of memory safety. At compile-time you have no such tools plus you might not even notice that the compiler is corrupted and produces wrong results. If you want |
2e30523
to
af9b270
Compare
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
tcastint.testCastRefOrPtr
future work
tyCstring
, egcast[int](someCstring)
example use case
nimyaml
works in VM even with ref types, see how much work needed to make it work at compile time? flyx/NimYAML#70 (comment)EDIT: and even with cyclic structures involving YAML anchors, see flyx/NimYAML#92 (comment)
(and after #15528 it works with const too)
when nimvm
and custom workarounds)