We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
/** * Comment */ typedef enum foo { bar = 1 } foo; int main() { }
Problematic piece of AST:
|-EnumDecl 0x5fd8be673708 <1.c:4:9, line:6:1> line:4:14 foo | |-FullComment 0x5fd8be673ae0 <line:2:3, col:10> | | `-ParagraphComment 0x5fd8be673ab0 <col:3, col:10> | | `-TextComment 0x5fd8be673a80 <col:3, col:10> Text=" Comment" | `-EnumConstantDecl 0x5fd8be6737e0 <line:5:5, col:11> col:5 bar 'int' | `-IntegerLiteral 0x5fd8be6737c0 <col:11> 'int' 1
Error:
panic: interface conversion: ast.Node is *ast.FullComment, not *ast.EnumConstantDecl goroutine 1 [running]: github.com/elliotchance/c2go/transpiler.transpileEnumDecl(0xc4200fe000, 0xc4200da500, 0xc420043490, 0xc4200fe000, 0x6dd920, 0xc4200da500, 0x0) c2go/transpiler/enum.go:222 +0x20d8 github.com/elliotchance/c2go/transpiler.transpileToNode(0x6dd920, 0xc4200da500, 0xc4200fe000, 0x0, 0x0, 0x0, 0x0, 0x0) c2go/transpiler/transpiler.go:487 +0x1fc
Fix:
diff --git a/transpiler/enum.go b/transpiler/enum.go index 800182a..f812445 100644 --- a/transpiler/enum.go +++ b/transpiler/enum.go @@ -219,7 +219,11 @@ func transpileEnumDecl(p *program.Program, n *ast.EnumDecl) (decls []goast.Decl, // counter for replace iota var counter int for i, c := range n.Children() { - e, newPre, newPost := transpileEnumConstantDecl(p, c.(*ast.EnumConstantDecl)) + cd, ok := c.(*ast.EnumConstantDecl) + if !ok { + continue + } + e, newPre, newPost := transpileEnumConstantDecl(p, cd) preStmts, postStmts = combinePreAndPostStmts(preStmts, postStmts, newPre, newPost) e.Names[0].Obj = goast.NewObj(goast.Con, e.Names[0].Name)
The text was updated successfully, but these errors were encountered:
Thanks for raising this @starius. It look like @Konstantin8105 already has a fix for this 👍
Sorry, something went wrong.
Typedef for union. Fixes #475, #496, #508, #522, #524 and #556 (#523)
7b46c33
No branches or pull requests
Problematic piece of AST:
Error:
Fix:
The text was updated successfully, but these errors were encountered: