Skip to content

Functional Checker for Go, developed for my Bachelor Thesis

License

Notifications You must be signed in to change notification settings

tommyknows/funcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Funcheck

Build Status

Funcheck is a Go linter that reports non-functional constructs. There is actually only one checker (assigncheck) which reports every case where we only assign variables (x = "whatever"), not combined by a declaration (x := "whatever"). See my Bachelor thesis for more info and background.

Currently, there is one exception to the above rule:

Anonymous function assignments. As it is not possible (because of scoping rules) to recursively call an anonymous function without declaring it first, this needed to be an exception. The following code block is not valid Go:

func x() {
    y := func(i int) int {
        if i == 0 {
            return -1
        }
        return y(i-1)
    }
}

As the function y is not in scope within y's body. To work around this, the following code works:

func x() {
    var y func(int) int
    y = func(i int) int {
        if i == 0 {
            return -1
        }
        return y(i-1)
    }
}

This is why this exception exists. However, this exception needs the function's declaration to be right before the function's assignment. This is not valid:

func x() {
    var y func(int) int
    z := 5
    y = func(i int) int {
        if i == 0 {
            return -1
        }
        return y(i-1)
    }
}

About

Functional Checker for Go, developed for my Bachelor Thesis

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages