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.

Conditional Local Functions are considered unused

See original GitHub issue
using System.Diagnostics;

public class C {
    public void M() {
        local();
        
        [Conditional("DEBUG")]
        static void local() {} // Warning: unused local function
    }
}

This reproes when compiling for release mode.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
RikkiGibsoncommented, Sep 4, 2020

(Hope I’m not causing any inconvenience while trying to make mini-contributions 😄 )

Absolutely not, we’re glad you’re here.

1reaction
RikkiGibsoncommented, Sep 4, 2020

I think the fix to this bug is to ensure that the appropriate analysis pass adds the local function to the set of used local functions, regardless of the presence of any ConditionalAttribute, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can we have unused functions but we can't ...
The behaviour seems consistent between variables and functions – both are allowed in a package-level scope, even if unused.
Read more >
Unused local variable in Python
A code with many unused local variables, unused imports, or unused line of codes is considered to be dead code. When there are...
Read more >
Unused variables vs unused functions · Issue #26080
So the compiler's behaviour is actually somewhat consistent. Unused vars inside a function are not allowed, while unused functions inside a ...
Read more >
Unused assignments should be removed
Unused assignments should be removed ... A dead store happens when a local variable is assigned a value that is not read by...
Read more >
Today: how to identify unused exported functions and variables
The obvious way to check for this is to use the -Wunused flag during compile, GCC will inform you about unused parameters, local...
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