E81006: cannot convert argument to required parameter type

Category: E81xxx-E83xxx Test configuration, execution and coverage · Classification: TYPE_CONVERSION_ERROR · All error codes

What went wrong

An argument in commandline_arg_{id}.txt cannot be converted to the type declared in the @Test program's parameter.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 953 (How do @Test programs work with command-line arguments...)

Example error

A '@Test' program 'Calculate()' whose parameter is an Integer, with a commandline_arg_test.txt holding "not_a_number", is this error: the argument cannot be converted to an Integer.

Supported parameter types

String, Integer, Float, Boolean, Character, Bits
Date (2025-12-31), Time (14:30:00), DateTime, Duration, Millisecond
Money ($100.00), Colour (#FF5733), Resolution (300dpi)
Dimension (100.5mm), RegEx, GUID, List of String

How to fix it

  1. Fix argument value to match expected type format
  2. Or change parameter type to String and parse in program
  3. Or create new commandline file with valid values

Examples

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

Fails with E81006: cannot convert argument to required parameter type - reported by the test runner, not the compiler, when ek9 -t greeting.ek9 runs in this project.

bad/greeting.ek9

#!ek9
defines module error.e81006.bad

  defines function

    greeting() as pure
      -> name as String
      <- result as String: `Hello, ${name}`

bad/dev/tests.ek9

#!ek9
defines module error.e81006.bad.tests

  references
    error.e81006.bad::greeting

  defines program

    @Test
    GreetingCases()
      -> times as Integer
      stdout <- Stdout()
      stdout.println(greeting(`${times}`))

bad/dev/commandline_arg_simple.txt

not_a_number

bad/dev/expected_case_simple.txt

Hello, 3
$ ek9 -t greeting.ek9
ℹ️ Found 1 test:
  1 assert (unit tests with assertions)

Executing 1 test...

❌ FAIL error.e81006.bad.tests::GreetingCases [Assert] (nms)
    Test configuration error: argument 1 'not_a_number' cannot be converted to Integer

Summary: 0 passed, 1 failed (1 total)
Types: 1 assert
Duration: nms
ek9: tests failed (exit 11)
E81006: cannot convert argument to required parameter type
  argument 1 'not_a_number' cannot be converted to Integer
  See: ek9 -h E81006

Fixed: The argument is an Integer

good/greeting.ek9

#!ek9
defines module error.e81006.good

  defines function

    greeting() as pure
      -> name as String
      <- result as String: `Hello, ${name}`

good/dev/tests.ek9

#!ek9
defines module error.e81006.good.tests

  references
    error.e81006.good::greeting

  defines program

    @Test
    GreetingCases()
      -> times as Integer
      stdout <- Stdout()
      stdout.println(greeting(`${times}`))

good/dev/commandline_arg_simple.txt

3

good/dev/expected_case_simple.txt

Hello, 3
$ ek9 -t greeting.ek9
ℹ️ Found 1 test:
  1 parameterized (1 cases total)

Executing 1 test...

✅ PASS error.e81006.good.tests::GreetingCases [Param:simple] (nms)

Summary: 1 passed, 0 failed (1 total)
Types: 1 parameterized
Duration: nms