Acknowledged

The type checker handles ByteArrays inconsistently

Given:

function foo(ba as ByteArray) as Void {
  ba[0] = 42; // no warning (correct)
  ba[1] = '*'; // no warning (correct)
  ba[2] = 42L; // warning (correct)
  ba[3] = 42f; // warning (correct)
  ba[4] = 42d; // warning (correct)
  ba[5] = "42"; // warning (correct)
}

The type checker recognizes that you can only assign Number or Char to elements of a ByteArray, and correctly warns for any other type. If you ignore the warnings and run the code anyway, everything except Number and Char results in an UnexpectedTypeException - so this is all good.

But given:

function bar(ba as ByteArray) as Number {
  return ba[1]; // incorrect warning that we're returning 'Any'
}

The compiler incorrectly warns that bar is returning Any:

ERROR: fenix5xplus:bug.mc:2: Object of type 'Any' does not match return type '$.Toybox.Lang.Number'.

which forces you to cast the result to Number.

Since the compiler clearly understands ByteArray (since it correctly enforces assignments to them) it should be able to correctly type the values extracted from them - its always Number, even if you put Chars in them.