-
-
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
complex constant doesn't work at c++ backend #9622
Comments
Changing |
I did notice that - I should have listed that as a workaround but this should work at compile-time. |
error: extra brace group at end of initializer
I tried with both C and C++ backend. Only with the c++ backend I could reproduce the problem. |
It happens for me using C backend as well though (Win 10, WSL, and just tried on Ubuntu). Is it related to gcc and maybe you're on a different compiler? |
I am on clang on Manjaro Linux. |
using nim 64016dd 1.5.1, it works (no codegen error) with either C or C++ all that's needed to close this issue is to minimize the above test case (too large IMO) and add a regression test |
no need to minimize, they compile and run fast. |
@xflywind minimized test case is better since it's less code to read and much more obvious to where the compiler was wrong before |
@Yardanico ok |
Reduced with Nim 0.19.2: type
GlobNodeKind = enum
LiteralIdent,
Group
GlobNode = object
case kind: GlobNodeKind
of LiteralIdent:
value: string
of Group:
values: seq[string]
PathSegment = object
children: seq[GlobNode]
GlobPattern = seq[PathSegment]
proc parseImpl(): GlobPattern =
if result.len == 0:
result.add PathSegment()
result[^1].children.add GlobNode(kind: LiteralIdent)
block:
const pattern = parseImpl()
doAssert $pattern == """@[(children: @[(kind: LiteralIdent, value: "")])]""" |
indeed. And also future changes in compiler/stdlib may hide the bug, so the un-minimized test would stop testing for the actual bug and act as a regression test. exampleimport std/strutils
proc main =
var s = ""
stripLineEnd(s) # was bug because of [^1] didn't work in VM (refs https://github.com/nim-lang/Nim/issues/16226)
static main() this would be a bad (or at least insufficient) regression test, because implementation of instead, a good regression test for that would not use strutils (eg #15987) |
Example
Sorry the source is a bit long, I've tried for a long time to reduce but couldn't narrow down as much as we'd all like.
source file
Current Output
Expected Output
No errors
Possible Solution
Additional Information
I tried on both these versions (stable & devel):
The text was updated successfully, but these errors were encountered: