On Tuesday, 11 June 2024 at 08:44:25 UTC, Richard (Rikki) Andrew Cattermole wrote:
There are two more corrections to make.

Both in sliceIt.

Note: array is a function not a type and is for ranges, slices are built in language concept. Associate Arrays (map) use the syntax ``Type[Type]``.

While I do understand what you're saying, I'm not sure I understand how to fix the code.

1. Changing function's argument type to `Array(string)` results in the following error: `Error: function declaration without return type.`

2. Adding function type `Array(string) sliceIt(...)` results in the following error: `Error: function declaration without return type.`

3. Finally, changing function's argument type to `string[]`, so function definition looks like this:
```
auto extract_arg_names(string[] def_words_arr){...};
```

results in, what I presume, is a runtime error:


```
core.exception.AssertError@definition/sliceit.d(42): unittest failure
----------------
??:? _d_unittestp [0x357a31]
??:? void arg.__unittest_L39_C1() [0x302495]
??:? void arg.__modtest() [0x34ba78]
??:? int core.runtime.runModuleUnitTests().__foreachbody6(object.ModuleInfo*) [0x37316a] ??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*)) [0x34dde3] ??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref rt.sections_elf_shared.DSO) [0x380257] ??:? int rt.sections_elf_shared.DSO.opApply(scope int delegate(ref rt.sections_elf_shared.DSO)) [0x382dd1] ??:? int rt.minfo.moduleinfos_apply(scope int delegate(immutable(object.ModuleInfo*))) [0x3801e5] ??:? int object.ModuleInfo.opApply(scope int delegate(object.ModuleInfo*)) [0x34ddb5]
??:? runModuleUnitTests [0x372fa0]
??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll() [0x372728] ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).tryExec(scope void delegate()) [0x3726b5]
??:? _d_run_main2 [0x37261e]
??:? _d_run_main [0x3723bf]
??:? main [0x34ba8d]
??:? __libc_start1 [0x82289eaf9]
/usr/src/lib/csu/amd64/crt1_s.S:83 _start [0x30213f]
??:? ??? [0xe83fb403007]
1/1 modules FAILED unittests
```

PS. Found more correction in the original code. The variable `def_words_arr` should just be `words_arr`. Was not paying attention when simplifying the code to post here.
  • Comparing slice ... madwebness via Digitalmars-d-learn
    • Re: Compari... madwebness via Digitalmars-d-learn
      • Re: Com... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
        • Re:... madwebness via Digitalmars-d-learn
          • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... madwebness via Digitalmars-d-learn
            • ... madwebness via Digitalmars-d-learn
              • ... madwebness via Digitalmars-d-learn
                • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn

Reply via email to