-
-
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
bugs with {.emit.} #13943
Comments
Can you elaborate a bit more on what the problem is? This test is one of the most important test that I wrote, so it would be good if it is correct. Unrelated to that, I would really like to have an |
that's shown in Example 3; I'm fixing this and other issues in #13953 (see
also fixing that in #13953 |
but tsizeof is tested in C++ mode |
it works in your test because you're only calling |
That's just you not understanding emit. |
summary
A1
emit: "foo `someNimVar` bar".}
can sometimes give wrong runtime results (which is worse than CT errors); the newer syntaxemit: [..]
doesn't have that issue though; EDIT: this happens in particular in templates and is related to "undeclared identifier" error when using fmt from strformat on devel inside a template #10977 and asm code in templates fail #2362A2
emit
doesn't work withvar
variables, but works withresult
pseudo-var-variableA3 block scope
emit
should not be relocatedA4
{.emit:"/*HERE*/ do not move me".}
should be introduced (trivial change); would be useful for module-scope emit's even ifblock scope
emit bug is fixedA5
tsizeof.c_sizeof
shows a seemingly correct usage ofemit
that is in fact incorrect and would be easily fixed with/*HERE*/
A6 nim cpp differs from nim c (related to A2)
Example 1
Current Output
Expected Output
works
Example 2
this prints:
the
procLevel
output is correct: the code is emitted where the emit is declaredBUG: the
blockLevel
output is incorrect: the code should not be moved around to a separate section because it's inside a blockit results in buggy behavior as illustrated here
the
moduleLevel
output is technically correct: the code is moved around to a separate section. However we need a new type section modifier:in addition to the existing
/*TYPESECTION*/, /*VARSECTION*/, /*INCLUDESECTION*/
.It should be a trivial change in
determineSection
Example 3
this is related to Example 2.
Here's the implementation from
tsizeof.c_sizeof
:nim c -r -f --stacktrace:off $timn_D/tests/nim/all/t10527b.nim
works, but shouldn't, because warnings are squashed => we really need #11591 which would enable showing those warnings via
--warning:BackendWarning:on
nim cpp -r -f --stacktrace:off $timn_D/tests/nim/all/t10527b.nim
this one fails (as it should) and illustrates the bug, which is that emit gets moved around to another section even though it's inside a block:
here's the generated code:
and here's the cgen error:
example 4:
nim cpp
differs fromnim c
nim c
returnsa: 262398120
(incorrect)nim cpp
returnsa: 10
(correct)Additional Information
The text was updated successfully, but these errors were encountered: