E07400: returning variable and type missing

Category: E07xxx Full resolution · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: RETURNING_MISSING · All error codes

What went wrong

A function or method that should return a value doesn't have a return declaration.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1319 (Why does EK9 reject an operator that takes a parameter...)

How to fix it

  1. Add return declaration
  2. Or ensure calling code doesn't expect return if void

Common causes

  • Forgot to add return variable
  • Copy from void function

See also

  • E07400: missing return declaration (this error)
  • E07405: control structure as expression without return

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E07400: returning variable and type missing

#!ek9
defines module error.e07400.bad

  defines class

    Counter
      count <- 0

      //'!' produces a value, so it must declare what it returns
      default operator ?

      operator ! as pure
        total <- count
        require total?

Fixed: Declare the returning variable

#!ek9
defines module error.e07400.good

  defines class

    Counter
      count <- 0

      default operator ?

      operator ! as pure
        <- rtn as Integer: count

Questions and answers

These Q&A entries show E07400 and its fix:

Found a problem?

If EK9 reported E07400 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.