Skip to content

Call func with anonymous func within if statement, cause parser stop. #1535

@Talos208

Description

@Talos208
  • There is a func that takes a func as an argument.
  • Call the func with anonymous function within if statement and user return value.
  • Parser stops from end of the function
    Here is a sample code.
package main

import "errors"

func bar(fn func() int) error {
    if fn() != 42 {
        errors.New("Not a answer for everything!")
    }
    return nil
}

func main() {
    if err := bar(func() int {return 42}); err != nil {
        panic(err)
    }
    // After here, parser stops and both function hilighting and auto-indentation doesn't work.
    print("You find answer for everything.\n")
    another()
}

func another() {
    // parser now works again
    print("Congraturation!")
}

2015-04-07 11 10 22

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions