Halp! type system (__expand_field_0 error), compile time/runtime questions (AoC-2017 puzzle spoilers inside)

Steven Schveighoffer schveiguy at yahoo.com
Thu Dec 14 16:38:26 UTC 2017


On 12/14/17 10:28 AM, aliak wrote:
> Then I get this error:
> 
>    Error: couldn't find field __expand_field_0 of type ulong in 
> Tuple(0LU, 117)
> 
> 117 is the ascii code for 'u' btw, which happens to be the first 
> character in my random input string. This error is coming from inside my 
> day 10's "solveB" function (which is imported in day 14 as 
> "knotHashHex"). It comes from here:
> 
>    int[] rotate(int[] list, int[] lengths) {
>      auto range = list.cycle;
>      foreach (skip, length; lengths.enumerate) { // <-- here is error
>        //  do stuff to range
>      }
>      return list;
>    }
> 
> So it says something about ulong and expanding a tuple type. But I'm 
> having a hard time with this error message.
> 
> Questions: What does it mean? It can't expand field 0 (the ulong) in to 
> my skip variable? Why not? And most importantly, why is it having 
> trouble here during my "process" function, but not screaming when I call 
> "grid.array" in my "solveB" function? What am I doing wrong?
> 

So enumerate returns as its element type a Tuple. Specifically, it's 
going to be a Tuple!(size_t, int), since you are enumerating an array of 
ints.

I'm not sure why you are having the error, compiling your code above 
works perfectly fine for me. It would help to know:

a) which version of the compiler you are using?
b) if the above actually does compile for you, what is the minimal code 
that does not?

All that aside, you may not realize, this works as well:

foreach(skip, length; lengths)

as arrays have special treatment in the compiler.

-Steve


More information about the Digitalmars-d-learn mailing list