Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics regression: getTypeInst causes issue with generic constraints #33

Open
mratsim opened this issue Jan 20, 2021 · 0 comments
Open

Comments

@mratsim
Copy link
Contributor

mratsim commented Jan 20, 2021

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

@mratsim mratsim changed the title Generics: getTypeInst causes issue with generic constraints Generics regression: getTypeInst causes issue with generic constraints Jan 21, 2021
mratsim added a commit to mratsim/constantine that referenced this issue Jan 21, 2021
mratsim added a commit to mratsim/constantine that referenced this issue Jan 21, 2021
* Pin nim-serialization. Workaround #113 and status-im/nim-serialization#33

* Need to workaround nimble installing dependency multiple times

* non-interactive

* UB sanitizer missing on mingw

* Fix OpenSSL benchmark on non-Linux platforms

* Accelerate CI:
- Skip 32-bit on 64-bit tests
- Only test leaf functionality.

* Don't define -fstack-protector-all with MinGW

* skip line functions and cyclotomic tests (already tested in pairing) + only compile the benches don't run them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant