Description
json.decode() without a type argument returns (any, error), but any is an internal-only type that users cannot declare or work with.
temp result, err = json.decode(jsonString)
// result has type 'any' - but what can the user do with it?
The user cannot:
- Declare a variable as
any: temp x any = ... is not allowed
- Pass it to a function expecting a concrete type
- Use it meaningfully without casting
Affected Functions
From pkg/typechecker/typechecker.go:4947-4956:
case "decode":
if len(args) >= 2 {
if label, ok := args[1].(*ast.Label); ok {
return []string{label.Value, "error"}
}
}
return []string{"any", "error"} // ← Problem
case "parse", "parse_file":
return []string{"any", "error"} // ← Same problem
Expected Behavior
Either:
- Require a type argument:
json.decode(text, MyType) - no untyped version
- Return a usable dynamic type that users can work with
- Document a pattern for working with untyped JSON (if one exists)
Current Workaround
Always provide a type argument:
temp result, err = json.decode(jsonString, MyStruct)
But if users don't know the type at compile time, they're stuck.
Description
json.decode()without a type argument returns(any, error), butanyis an internal-only type that users cannot declare or work with.The user cannot:
any:temp x any = ...is not allowedAffected Functions
From
pkg/typechecker/typechecker.go:4947-4956:Expected Behavior
Either:
json.decode(text, MyType)- no untyped versionCurrent Workaround
Always provide a type argument:
But if users don't know the type at compile time, they're stuck.