microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

(python) Capture Avoiding Substitution preserves type #938

Closed acl33 closed 3 years ago

acl33 commented 3 years ago

This is nearly trivial - but where ExprTransformer preserves the type of things it copies: https://github.com/microsoft/knossos-ksc/blob/333c2ec4ed53f2818810a902aea52b57b8f94ce3/src/python/ksc/visitors.py#L95

The capture-avoiding substitution code overrides that and drops the type. Hence, add it back in.

I haven't added a test, as it seems that this would largely just repeat the lines added. But it might be useful as a regression check, so happy to add one if anyone feels I should.