Skip to content

Generics regression: getTypeInst causes issue with generic constraints #33

@mratsim

Description

@mratsim

In Constantine the following type used to be deserializable.

https://github.com/mratsim/constantine/blob/023e690/tests/t_ec_sage_template.nim#L95-L100

type
  TestVector*[EC: ECP_ShortW_Aff] = object
    id: int
    P: EC
    scalar: matchingScalar(EC)
    Q: EC

It now breaks mratsim/constantine#113
image

The stacktrace points to getTypeInst

for field in recordFields(typeImpl):
if field.readPragma("dontSerialize") != nil:
continue
let
fieldType = field.typ
FieldTypeSym = getTypeInst(fieldType)

/home/beta/Programming/Nim/constantine/tests/t_ec_sage_bls12_377.nim(18, 28) template/generic instantiation of `run_scalar_mul_test_vs_sage` from here
/home/beta/Programming/Nim/constantine/tests/t_ec_sage_template.nim(192, 26) template/generic instantiation of `loadVectors` from here
/home/beta/Programming/Nim/constantine/tests/t_ec_sage_template.nim(178, 16) template/generic instantiation of `loadFile` from here
/home/beta/.nimble/pkgs/serialization-0.1.0/serialization.nim(96, 11) template/generic instantiation of `readValue` from here
/home/beta/.nimble/pkgs/serialization-0.1.0/serialization.nim(46, 9) template/generic instantiation of `readValue` from here
/home/beta/.nimble/pkgs/json_serialization-0.1.0/json_serialization/reader.nim(497, 11) template/generic instantiation of `totalSerializedFields` from here
/home/beta/.nimble/pkgs/serialization-0.1.0/serialization/object_serialization.nim(179, 36) template/generic instantiation of `totalSerializedFieldsImpl` from here
/home/beta/.nimble/pkgs/serialization-0.1.0/serialization/object_serialization.nim(176, 26) template/generic instantiation of `enumAllSerializedFields` from here
/home/beta/.nimble/pkgs/serialization-0.1.0/serialization/object_serialization.nim(153, 32) template/generic instantiation of `enumAllSerializedFieldsImpl` from here
/home/beta/.nimble/pkgs/serialization-0.1.0/serialization/object_serialization.nim(104, 33) Error: cannot instantiate TestVector
got: <EC: ECP_ShortW_Aff>
but expected: <EC: ECP_ShortW_Aff>

Another instance of nim-lang/RFCs#44

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions