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

Remove function$ entirely. #7208

Merged
merged 3 commits into from
Dec 21, 2024
Merged

Remove function$ entirely. #7208

merged 3 commits into from
Dec 21, 2024

Conversation

cristianoc
Copy link
Collaborator

No description provided.

@cristianoc cristianoc force-pushed the remove-function$-entirely branch 3 times, most recently from cc48899 to c250201 Compare December 20, 2024 14:58
@@ -1195,7 +1195,9 @@
addValueReference OptArg.res:1:4 --> OptArg.res:1:29
addValueReference OptArg.res:3:4 --> OptArg.res:3:17
addValueReference OptArg.res:3:4 --> OptArg.res:3:27
DeadOptionalArgs.addReferences foo called with optional argNames:x argNamesMaybe: OptArg.res:5:7
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to look into these changes: the loc of parameters has changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes appear to be correct.

@@ -9,11 +9,12 @@ ContextPath Value[someFunc]
Path someFunc
argAtCursor: unlabelled<0>
extracted params:
[int, ~two: string=?, ~three: unit => unit, ~four: someVariant, unit]
[(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to look into these changes: the loc of parameters has changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this function type:

type t = (  x: int
         ^  ^
         f  t

The parser updates the location of the top-level node to start at location f.

So in the case of function$< Tarrow> the top-level node starts at f and the Tarrow node starts at t.
Now that Tarrow is the top-level node, it starts at f.

Neither is optimal, perhaps at some point one could consider a better representation of function types, where the locations of the overall type, and individual labels is straightforward. (Labels themselves are a little funny with optional parameters).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @zth

@cristianoc cristianoc force-pushed the remove-function$-entirely branch from c250201 to c2f8cca Compare December 20, 2024 15:16
@cristianoc cristianoc changed the base branch from remove-function$ to master December 20, 2024 15:17
@cristianoc cristianoc force-pushed the remove-function$-entirely branch 2 times, most recently from 49acad1 to 674c4bf Compare December 20, 2024 15:32
@cristianoc cristianoc force-pushed the remove-function$-entirely branch from 674c4bf to b71324f Compare December 20, 2024 18:49
@cristianoc cristianoc requested review from cknitt and zth December 21, 2024 11:56
@@ -132,7 +132,7 @@ type t = @attr (foo, @attr2 ~f: bar, @attr3 ~f: baz) => unit
type t = @attr (string => @attr (int => unit))
type t = @attr (string, int) => @attr (int, float) => unit
type t = @attr (int => @attr (int, float) => @attr (unit => unit => unit))
type t = @attr (@attr2 ~f: int, @attr3 ~g: float) => unit
type t = (@attr @attr2 ~f: int, @attr3 ~g: float) => unit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't look correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a single node.
No way to distinguish inside and outside the parens.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought @attr was on the whole function and @attr2 was on the first arg.
So what exactly are @attr and @attr2 on now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Later on, a good representation should probably take a list of params, each one with its own locations and attributes.
Then the single function node could have its own location and attributes.

We're bound to having to convert back and forth with the original parse tree for ast compatibility, so either one would have to preserve all information,or at least all the info required for the later phases of the compiler (other than pretty printing).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought @attr was on the whole function and @attr2 was on the first arg.

So what exactly are @attr and @attr2 on now?

The only attributes are at the level of ast nodes.
The type (a, b) => c is just a pretty printed form for 2 ast nodes. (The outer one has the arity info).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So (a,b) => c is really a =2=> (b => c)
Attributes are on the arrow nodes so the there's no distinction between an attribute on a, and on the whole type: it's the same node, the outer one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleaning up these things is exactly what we need custom asts for.
This aspect can be cleaned up in a further refinement.

@cknitt
Copy link
Member

cknitt commented Dec 21, 2024

Tested against a real world project without any issues!

@cristianoc cristianoc merged commit 6f24778 into master Dec 21, 2024
20 checks passed
@cristianoc cristianoc deleted the remove-function$-entirely branch December 21, 2024 19:32
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 this pull request may close these issues.

2 participants