Skip to content

Layouts (Stage 2): Print inferred layout more consistently on locally-abstract types#29

Closed
ncik-roberts wants to merge 2 commits intolayouts1from
layouts2
Closed

Layouts (Stage 2): Print inferred layout more consistently on locally-abstract types#29
ncik-roberts wants to merge 2 commits intolayouts1from
layouts2

Conversation

@ncik-roberts
Copy link
Copy Markdown
Contributor

@ncik-roberts ncik-roberts commented Nov 30, 2023

Fix a bug where layout would be printed the first time the user queried an abstract type, but only the second time that the user queried a locally-abstract type. This is an omission in flambda-backend, so I'm posting a corresponding PR there: oxcaml/oxcaml#2115. We need not merge this merlin-jst PR; we can just wait until we pick up the flambda-backend change in the normal merge process.


Old approach that we're no longer taking (we never show layouts when the user asks for the type of a value anymore):


Previously, when you asked for the type of a value (the second time), merlin wouldn't print a type declaration if the type was abstract. E.g. asking for the type of 4 will only ever print int, not type int. But this means that there isn't a sensible places to hang a layout annotation.

Now, merlin always prints a type declaration for Tconstrs when you ask for the type of a value the second time.

This is a bit weird for locally-abstract types, where we print type a : immediate. We could print a : immediate instead, but I think we should be consistent. That is, we should either:

  • print int : immediate and a : value
  • print type int : immediate and type a : value

I prefer the second because it's more uniform with how we handle non-abstract Tconstrs.

@ncik-roberts ncik-roberts changed the title Print type declaration, and thus inferred layout, in more cases Layouts (Stage 2): Print type declaration, and thus inferred layout, in more cases Nov 30, 2023
Signed-off-by: Nick Roberts <nroberts@janestreet.com>
Signed-off-by: Nick Roberts <nroberts@janestreet.com>
@ncik-roberts ncik-roberts changed the title Layouts (Stage 2): Print type declaration, and thus inferred layout, in more cases Layouts (Stage 2): Print inferred layout more consistently on locally-abstract types Dec 2, 2023
@ncik-roberts ncik-roberts marked this pull request as draft December 2, 2023 03:01
@ncik-roberts
Copy link
Copy Markdown
Contributor Author

Closing as oxcaml/oxcaml#2115 was merged.

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.

1 participant