E50060: method/function not resolved

Category: E50xxx Common errors · Reported in phase: FULL_RESOLUTION · Classification: METHOD_NOT_RESOLVED · All error codes

What went wrong

The compiler cannot find a method matching both the NAME and PARAMETER TYPES you specified. EK9 requires exact parameter type matches.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 4 (How do I read input from the user?)
  • ek9 -q 2 (How do I compile and run an EK9 program?)
  • ek9 -q 12 (How do I install EK9?)
  • ek9 -q 18 (How do I add comments to my code?)
  • ek9 -q 20 (What file extension does EK9 use?)

Debugging method chains

Break the chain to find where it fails: take each call's result into a variable of its own, then ask of each one what type it is, and whether that type has the next method in the chain.

How to fix it

  1. Check exact method name spelling
  2. Check parameter types match exactly (EK9 doesn't auto-convert)
  3. For overloaded methods, ensure you're using correct overload
  4. For chains, check what each step returns

Common causes

  • Method name typo
  • Wrong parameter type (no matching overload)
  • Wrong parameter count
  • In chains: intermediate step returns different type than expected
  • Constructor call with arguments that don't match any declared constructor (especially when passing an undeclared type or a literal of the wrong numeric kind as a constructor argument)
  • Constructing a Panic: 'Panic(...)' (any arguments, or none) is this error, because Panic has no constructors EK9 code can call - only the language raises one. Use require or a constrained type, or throw an Exception with the exit code you want (ek9 -q 1434)

Cascade note

E50060 on a constructor call typically causes E50010 ('type not resolved') on every subsequent use of the variable being constructed: when 'Order(money, "Alice")' matches no constructor, the variable it initialises has no type, so printing it and reading its fields each report E50010 as well.

Fix the constructor call first and the cascaded E50010 errors disappear. Counting 'errors-to-fix' by totalling the compiler output will overstate the work required — the downstream errors are symptoms, not separate bugs.

See also

  • E50060: method not found (this error)
  • E06180: method exists but not accessible (private/protected)
  • E07620: operator not defined on type
  • E06140: multiple methods match equally well (ambiguous)

https://ek9.io/methods.html https://ek9.io/forAI.json#$.methodResolution

Examples

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

Fails with E50060: method/function not resolved

#!ek9
defines module error.e50060.bad

  defines class

    Counter
      describe()
        -> count as Integer
        <- rtn as String: $count

  defines function

    demo()
      <- rtn as String?
      counter <- Counter()
      rtn: counter.describeAll()

Fixed: Call a method that exists, with the arguments it declares

#!ek9
defines module error.e50060.good

  defines class

    Counter
      describe()
        -> count as Integer
        <- rtn as String: $count

  defines function

    demo()
      <- rtn as String?
      counter <- Counter()
      rtn: counter.describe(42)

Questions and answers

These Q&A entries show E50060 and its fix: