question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird behaviour with Structs

See original GitHub issue

I feel the following is an issue because the full code compiles, which indicates it is a valid construction. I don’t know much about structs in C++ though.

Anyway, the following is handled strangely (can see easier in Atom).

struct Scanner {

  vector<CategoryDescription> category_descriptions = {
    {FOO, FOO, FOO},
    {FOO, FOO, FOO}
  };

  map<string, TokenType> tokens = {
    {"(", BEGIN_INLINE_MATH},
    {")", END_INLINE_MATH},
  };

  map<char, Category> catcodes = {
    {'\\',   ESCAPE_CATEGORY},
    {'{',    BEGIN_CATEGORY}
  };

};

The first item is scoped differently to the others, and reordering them or adding fields above does not affect this (whatever the first is is still scoped differently).

It also folds incorrectly; folding line 1 folds up until the semicolon of the vector, when it should be folding the entire struct.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
maxbrunsfeldcommented, Nov 18, 2018

Fixed on Atom master! I hate to see Tree-sitter failing you while you’re working on a Tree-sitter parser (guessing from your example). Thanks for raising this!

1reaction
thomasjocommented, Nov 18, 2018

~It’s not related to structs. The problem is that list initialization is not currently supported by the grammar.~ Nope, @Aerijo was correct all along.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C structs strange behaviour - Stack Overflow
The strange thing, is that the output of my program is dependent on the order in which I declare the components of this...
Read more >
Strange behaviour with C30 and structs
[edit 13-2-2013] I've seen another strange behaviour in the declaration of my structs: struct MenuStruct Menu[AANTALMENUS] __attribute__((space( ...
Read more >
Floating Point Numbers, Odd Behaviour and What You Should ...
Data Structures & Optimization. Floating Point Numbers, Odd Behaviour and What You Should Really Know (Data Structures & Algorithms).
Read more >
Strange behaviour on sub-structures · Issue #130 · jinzhu/copier
My initial goal is to have a duplicate function. I'm using this function (with a recover) in my production environment with copier version...
Read more >
Strange behaviour of json marshal of embedded struct
I really do not like this. I had an ugly bug in my code. What do you mean will be result of json...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found