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

No polymorphic closures #904

Closed
Tracked by #416
acl-cqc opened this issue Apr 2, 2024 · 2 comments · Fixed by #906
Closed
Tracked by #416

No polymorphic closures #904

acl-cqc opened this issue Apr 2, 2024 · 2 comments · Fixed by #906
Assignees
Milestone

Comments

@acl-cqc
Copy link
Contributor

acl-cqc commented Apr 2, 2024

  • Only FuncDefn (and FuncDecl) may declare binders
  • Type hierarchy includes monomorphic function types only, not polymorphic ones.
  • Two distinct EdgeKinds: one for values/closures (from Consts to their uses, including CallIndirect), i.e. no polymorphism; and one for functions (carries a polymorphic function type from a FuncDecl/Defn to a Call, only).
  • Thus, no TypeApply, but Call does type application, as per fix: polymorphic calls #901
  • Should simplify substitution logic as we no longer need to substitute polymorphic types in place of type variables, and don't need to substitute under binders (binders are only at the outermost level - function or opdef)
@croyzor
Copy link
Contributor

croyzor commented Apr 8, 2024

The spec says that a FuncDefn is the child of a dataflow container, meaning that they can be nested. Should this be updated to say that FuncDefn can only be the child of a Module?

@acl-cqc
Copy link
Contributor Author

acl-cqc commented Apr 8, 2024

The spec says that a FuncDefn is the child of a dataflow container, meaning that they can be nested. Should this be updated to say that FuncDefn can only be the child of a Module?

No - but nesting is purely for namespacing/scoping (a "local" funcdefn can only have nonlocal edges to things within the same parent). A local funcdefn already cannot refer to any enclosing TypeParams, this is checked in validation.

github-merge-queue bot pushed a commit that referenced this issue Apr 9, 2024
* Type::Function now stores only a FunctionType, not a PolyFuncType
* PolyFuncType remains, for OpDef's and FuncDefn/Decl's
* EdgeKind::Static now replaced by EdgeKind::Const (a type)
EdgeKind::Static (a PolyFuncType)
* Remove LeafOp::TypeApply, repurpose validation code onto Call
* Thus, progressively remove all `impl Substitution`s except for `struct
SubstValues`, which can become Substitution
* Update spec, introducing "Static" and "Dataflow" edge kinds as broader
classes of the other edge kinds, and polymorphic "type schemes" vs
monomorphic "Function types".
* Update serialization schema and add roundtrip test of a Noop operating
on a value of function type

fixes #904

This should enable resolving #788 and related capture/closure issues if
we forbid edges into a FuncDefn from outside (@doug-q)

BREAKING CHANGE: EdgeKind::{Static -> Const}, add new
EdgeKind::Function, Type contains only monomorphic functions, remove
TypeApply.
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

Successfully merging a pull request may close this issue.

3 participants