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
question: commented unreachable code #343
Comments
my guess: code coverage + think really hard |
You two are cracking me up. You're close. It was code coverage + a robust test suite + thinking really hard. |
If I find a commented piece of reachable code, will you transfer me some karma points? |
Sure thing. Your name and contribution will be immortalized in the CHANGELOG. |
Doing some fuzzing, I was able to reach more unreachable code. I've uncommented the unreachable comments and placed a function call |
Thanks for looking into this. Regarding Try commenting out those lines and then running the following code: console.log(JSON5.stringify({a: '"'}, {quote: '"'})
// {a:"undefined"}
// should be {a:"\""}
// undefined is inserted because `replacements` does not have a key for `"` Regarding the unreachable code in The In every case where the If you find any reachable code marked as unreachable in any other case besides |
It seems like every time I feel like I finally got you cornered, you manage to weasel your way out of the situation! The day will come where I find a bug in your code! https://github.com/mqnc/json5cpp Happy about remarks and feedback! I stuck to the reference implementation as closely as possible. Stringify does not have replacing/filtering yet and a reviver makes no sense in C++, it needs a different mechanism to convert parsed json to custom objects. I haven't done that yet. Currently I am trying to convince github to do a coverage report for me, I have never used the github CI before. As I have now dug through all the js reference code, my verdict is that it's very well written! I appreciate its brevity, especially in comparison to other projects. |
Congrats on implementing a C++ parser. When you're ready, feel free to add it to In the Wild. I'll take a closer look at your code when I get a chance. I agree that line could have been written in a less confusing way. When I first wrote the codebase, I wasn't really thinking about it being a reference parser. I was just trying to make something that works. I really should go back and add comments to make things clearer. That line chooses which quote character to wrap a string with based on the quote character that is used the least in the string. For example, the string |
The parser code contains lots of these comments:
It looks like there was this code before but it was taken out by some sort of reachability analysis. Is there some tool for this which proves the unreachability of certain code parts or did you sit down with pen and paper and think really hard? 😉
The text was updated successfully, but these errors were encountered: