Skip to content

[BUG] Assertion failure on malformed type alias definition #712

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

Closed
cpp-niel opened this issue Sep 30, 2023 · 1 comment
Closed

[BUG] Assertion failure on malformed type alias definition #712

cpp-niel opened this issue Sep 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@cpp-niel
Copy link

Describe the bug
The cppfront compiler terminates with an assertion failure when a type alias definition incorrectly uses = instead of ==.

To Reproduce
Steps to reproduce the behavior:

  1. Sample code - distilled down to minimal essentials please
    The behaviour can be reproduced by trying to compile this code:
abc: type = {
    a: int;
}

xyz: type = abc;
  1. Command lines including which C++ compiler you are using

simple compilation without any additional command line arguments triggers the problem

  1. Expected result - what you expected to happen

A syntax error from the compiler

  1. Actual result/error
cppfront: source/cppfront.cpp:5356: void cpp2::cppfront::emit(const cpp2::declaration_node&, const std::string&): Assertion `n.initializer && n.initializer->is_compound()' failed.
Program terminated with signal: SIGSEGV
Compiler returned: 139

Additional context
Compiler explorer link: https://godbolt.org/z/6ceYTeMYP

@cpp-niel cpp-niel added the bug Something isn't working label Sep 30, 2023
@hsutter
Copy link
Owner

hsutter commented Sep 30, 2023

Thanks!

zaucy pushed a commit to zaucy/cppfront that referenced this issue Dec 5, 2023
Semantic checks for things the user shouldn't be able to write even as input to a metafunction can be done early, in `parse`

Other semantic checks go in `sema` so that metafunctions have more liberty to take otherwise-incomplete definitions and complete them with the metafunction's own defaults (or do things like remove a member and replace it with something else that is complete)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants