rillig / gobco

Measure branch coverage of golang tests
62 stars 12 forks source link

undefined: gobco8 #30

Closed 503440692 closed 10 months ago

503440692 commented 10 months ago

image image Hi rillig, thank you for developing the tool: gobco. I have encountered some issues while using the tool. Please refer to the two images above for the problem details. It would be appreciated if you could help me resolve this issue.

rillig commented 10 months ago

Hi, the code in the screenshot looks quite normal to me. Please send me the whole file, or a reduced version of it that still reproduces the bug. You can run gobco -keep to look at the instrumented files, to see where the declaration of gobco8 is missing.

rillig commented 10 months ago

Got it. A minimum reproducer is:

switch any(3).(type) {
case uint8:
default:
    switch 1 + 1 {
    case 2:
        break
    }
}

When instrumenting a switch statement inside a type switch statement, gobco doesn't declare the expression from the inner switch statement. I'm working on a fix.

rillig commented 10 months ago

I fixed this bug in release 1.3.2. Thanks for your report.