Bug 19411 – Visual D Intellisense chokes on static ifs

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
visuald
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2018-11-18T10:54:27Z
Last change time
2018-12-22T15:19:17Z
Assigned to
No Owner
Creator
John Chapman

Attachments

IDFilenameSummaryContent-TypeSize
1719WindowsApp2.dCode to repro issue 19411text/plain49069

Comments

Comment #0 by johnch_atms — 2018-11-18T10:54:27Z
Intellisense seems to choke on long series of "static if" statements. It works fine with up to about 1000 lines of static ifs, but then stops working if you go over that. I've also observed that CPU usage for DParser increases a lot (about 28% on my Core i3 with 8GB RAM). If I replace "static if" with just "if", Intellisense starts working again (and CPU usage goes back down to 0%-8%).
Comment #1 by r.sagitario — 2018-12-06T07:38:03Z
I just tried to reproduce this with a series of more than 2000 "static if(size_t.sizeof == 4) {}", but didn't see a problem. Also using "else static if" worked alright. Maybe this has been fixed with the latest release, but I suspect this might have to do with some analysis taking too long, that isn't done when using regular "if" only. Could you please check again and try to reduce the code to a amaller size or attach the full example? Thanks.
Comment #2 by johnch_atms — 2018-12-06T08:31:51Z
Created attachment 1719 Code to repro issue 19411
Comment #3 by johnch_atms — 2018-12-06T08:35:39Z
I tried again with version 0.48.0 and it still happens. In fact it's now occuring with regular "if"s as well. I've attached code that triggers this. I checked my error logs and whenever this happens DParserCOMServer.exe appears with exception code 0xc00000fd - System.StackOverflowException.
Comment #4 by r.sagitario — 2018-12-07T08:03:01Z
Thanks. It's a builtin limitation of the recursive descend parser because the if/else-series creates a deep tree of AST nodes. Even if optimized in the parser the same problem will appear during analysis. I will increase the stack size to 8 MB, similar to dmd. dmd also chokes at some point, e.g. module mod; string genIfElse(int n) { string s = "if(size_t.sizeof == 4) {}\n"; foreach(i; 0..n) s ~= "else if(size_t.sizeof == 4) {}"; return s; } void test() { mixin(genIfElse(5000)); }
Comment #5 by r.sagitario — 2018-12-22T15:19:17Z