E50010: type not resolved

Category: E50xxx Common errors · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: TYPE_NOT_RESOLVED · All error codes

What went wrong

The compiler cannot find a TYPE with this name in the current scope. This applies to classes, records, traits, functions, and other type names.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 26 (Why does EK9 not have primitives?)
  • ek9 -q 23 (What basic types does EK9 have?)
  • ek9 -q 46 (How does the Dict type work in EK9?)

Cascading error note

If you see MULTIPLE E50010 errors, fix the EARLIEST one first. Later errors often cascade from an unresolved type earlier in the file: a variable initialised from 'NonExistent()' on line 10 has no type, so a call on it on line 20 fails too - fix line 10 and line 20 resolves by itself.

How to fix it

  1. Check spelling - EK9 is case-sensitive for types
  2. Add reference statement for types from other modules
  3. For generics: ensure 'of T' parameter is provided
  4. Fix earliest error first if multiple appear

Common causes

  • Type name misspelled
  • Missing 'of T' generic parameter
  • Type in different module without reference statement
  • A fully qualified type 'M::X' where module M only IMPORTS X with 'references' - qualify it with the module that DEFINES it (the message names it)
  • Using type name instead of instance (use `obj <- Type()` not `Type.method()`)

See also

  • E50010: TYPE not found (this error)
  • E50001: variable/identifier not found
  • E03030: reference module path doesn't resolve

Examples

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

Fails with E50010: type not resolved

#!ek9
defines module error.e50010.bad

  defines record

    Widget
      label as String: "widget"

      default operator ?

  defines function

    describe()
      -> item as Widgit
      <- rtn as String: "unknown"
      if item?
        rtn: item.label

Fixed: Spell the type as it is declared - or declare it

#!ek9
defines module error.e50010.good

  defines record

    Widget
      label as String: "widget"

      default operator ?

  defines function

    describe()
      -> item as Widget
      <- rtn as String: "unknown"
      if item?
        rtn: item.label

Questions and answers

These Q&A entries show E50010 and its fix: