8000 Type: an alias field can't be parsed, and nothing says what an alias stands for · Issue #530 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Type: an alias field can't be parsed, and nothing says what an alias stands for #530

Closed

Description

@akoskovacs

Type.Field.parse (#529) fails on a field whose type is an alias, and Type gives no way to find what the alias stands for, so a library decoding rows can't read it.

type UserId = String
record User do
  id : UserId
end

main do
  Type.of(User).fields.each { |f| IO.printLine("${f.valueType.name} ${f.parse("u1")}") }
end

On main at 6fdaf4c this prints UserId Error(Field "id": Expected UserId, got "u1"). valueType is UserId, with no args, no constructors and no fields, so there's no way to tell it is String.

Expected: parse reads an alias as what it aliases (Ok("u1")), and Type says what an alias stands for (for example a Type.resolved, or valueType naming String with the alias kept beside it).

Harmat (Harmat.Database.read) reads an alias field as plain text until this is possible. That's wrong for type Count = Integer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0