-
Notifications
You must be signed in to change notification settings - Fork 160
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
Change hint propagation for user-defined structs. #434
base: master
Are you sure you want to change the base?
Conversation
To address the compatibility issues noted in #398.
@marcoct Any thoughts on how / where we should document these changes? I can't think of a natural place it fits in the docs. |
@ztangent I think Extending Gen would make sense. |
@ztangent This looks great! My only comments are:
I'll also create another issue for adding support for AD through these structs. |
This feature works on any structs which can be "constructed-by-field", i.e. if the struct is defined as: struct Foo
field1
field2
field3
...
end then in order to propagate per-field changes,
struct EvilStruct
x::Int
y::Int
EvilStruct(x, y) = new(y, x)
end Unfortunately, it doesn't seem like there's any way to detect cases like this without looking up the IR of the constructor and doing some fancy analysis. So type-based solution I came up with is "complete but unsound", in that it will work without complaint for any constructor, but for some constructors changes will be propagated inaccurately. I would prefer a "sound but incomplete" approach, but as of now, I think the only way to do that is to always return "UnknownChange", because there's no way to distinguish constructor like It'd be great if you have thoughts on the best approach given these constraints @marcoct ! |
Added documentation here! Here's how I've stated the scope of
|
Finishes the implementation of
Construct
andGetField
started by @georgematheos in #367. Also adds tests, and some logic to handle cases where types have non-default constructors (although this is not exhaustive, because we can't prevent users from writing pathological constructors).