hrj/abandon

Show warning when a symbol is not used

hrj opened this issue · 7 comments

hrj commented
Show warning when a symbol is not used

Hi @hrj , could you please point me in the right direction here - I'm not sure what this issue is about...

hrj commented

@gerdreiss This is similar to programming languages, where you define a function or symbol but never use it, and the compiler issues a warning because it typically indicates a typo. For example:

def x1 = 10
def x2 = 20

def f1 = x1 * 30
def f2 = x1 * 30

Here x2 is defined but not used, probably because of a typo in definition of f2.

However, one caveat: Implementing this would require adding mutable state to the system. Would be nice to restrict mutability as much as possible.

@hrj
Ok, I think I've got an idea now, although I might need an example as I don't seem to be able to create one myself....

hrj commented

@gerdreiss Simplest example is a one liner:

def x = 10

Since x is defined but not used, abandon should emit a warning, along the lines:

input.ledger:1 : symbol `x` defined here but never used
hrj commented

@gerdreiss Heh.. Yeah, we need to document all these features sometime, in the wiki.

Note that the symbols are defined within a scope and scopes can be nested. So, we need to track the symbol's fully qualified path and not just the name.

hrj commented

Closed via #147