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

Update pre-null-safety spec with new null safety sections #2023

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Dec 10, 2021

This PR was created by deleting the sections from Subtypes to (but not including) Reference plus the appendix Algorithmic Subtyping, and inserting the section Subtypes from the null safety update branch plus all the following sections until (but not including) Reference, plus the new version of the appendix Algorithmic Subtyping.

The point is that this PR introduces a large chunk of the new material related to null safety which is introduced into the language specification, and it does not include all the small changes to sections that are mostly the same as before (those changes will be submitted as other PRs later on). In other words, the text before Subtyping is unchanged (apart from the fixes mentioned below), and references from the new material to any location before Subtyping may thus very well refer to obsolete language.

A couple of other updates were necessary in order to make the result LaTeX'able:

  • dart.sty was updated to be the version used with the null safety PR (the new version includes a number of declarations that are used by the material about null safety).
  • dartLangSpec.tex was updated to use \Delta rather than \Gamma to denote a type variable environment (that's the common notation; we previously used \Gamma, but that's typically a "term" variable environment, so \Delta would be less confusing for readers who also read research papers involving type systems).
  • \RawFunctionTypeNamed was updated to allow for the required modifier; a couple of changes were necessary in sections before Subtyping in order to make dartLangSpec.tex LaTeX'able again, but this only involved adding the new LaTeX macro argument {r}, further updates will take place later on (this update just updates stuff from Subtyping and out).
  • The symbol used to indicate that a word or phrase is being defined was changed from \diamond to \triangle, because \triangle is now also used over = in order to indicate that a certain term of the form A = B defines A.
  • Compile-time errors are now also indicated in the margin (using an \ominus symbol, similar to the symbolic traffic sign meaning "No entrance"), this symbol is used in the new material, that is, nowhere before section Subtyping; for instance, it occurs in section Type Null.

Unfortunately, the diff algorithm in git (and, probably, almost any diff algorithm) does not quite understand that the operation performed here is "delete two big chunks of text and insert replacements that are mostly new material", but it does seem to get on track after a while.

@eernstg
Copy link
Member Author

eernstg commented Jan 6, 2022

An update fixing a few issues with interface types is on the way, will upload in half an hour, approx. ;-)

@eernstg
Copy link
Member Author

eernstg commented Jan 6, 2022

Done.

@github-actions
Copy link

github-actions bot commented Jan 10, 2022

Visit the preview URL for this PR (updated for commit 6cd9296):

https://dart-specification--pr2023-specify-null-safety-56htdccy.web.app

(expires Mon, 11 Jul 2022 14:42:40 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6941ecd630c4f067ff3d02708a45ae0f0a42b88a

@chloestefantsova
Copy link
Contributor

chloestefantsova commented Apr 27, 2022

I skimmed over the changes and created the following checklist. I plan to review the text in parts and cross them out here when I'm done. The checklist itself may change in the future in case I missed anything.

  • Subtype algorithm.
    • Rules of inference.
    • Subsequent commentary.
  • Type nullability.
  • Top merge.
  • IsTopType.
  • Moretop, morebottom.
  • Type normalization.
  • Canonical syntax of types.
  • Standard bounds.
  • Closures of types.
  • Specific kinds of types
    • Types bounded by types.
    • Class building types.
    • Interface types.
    • Intersection types.
    • Never.
    • Null.
    • Type.
    • Function.
    • dynamic.
  • Type inference.
    • Flow analysis.
    • Type promotion.
  • Appendix. Algorithmic subtyping.

@chloestefantsova
Copy link
Contributor

chloestefantsova commented Apr 29, 2022

I checked the part "Rules of Inference", in the green "after" column the lines range from 20728 to 20889. It looks good to me.

EDIT: In my review I assumed that the requirement for the bounds of two function types is to be in the mutual-subtypes relationship. After a conversation with Erik I realized that the spec needs to be updated to mean that.

@chloestefantsova
Copy link
Contributor

I reviewed the part "Subsequent commentary" to the subtype algorithm, in the green "after" column the lines range from 20889 to 21291. I have two drive-by questions to the surrounding text. Otherwise, the part LGTM.

@chloestefantsova
Copy link
Contributor

I checked the part "Type Nullability", in the green "after" column the lines range from 21291 to 21414. I have left some comments, but otherwise LGTM.

@chloestefantsova
Copy link
Contributor

I checked the part "Top merge", in the green "after" column the lines range from 21414 to 21494. LGTM with one comment.

@chloestefantsova
Copy link
Contributor

I checked the part "IsTopType", in the green "after" column the lines range from 21494 to 21539. It LGTM.

@chloestefantsova
Copy link
Contributor

chloestefantsova commented May 17, 2022

I checked the part "Moretop, morebottom", in the green "after" column the lines range from 21539 to 21582. LGTM.

@chloestefantsova
Copy link
Contributor

I checked the part "Type normalization", in the green "after" column the lines range from 21582 to 21737. LGTM with one question.

@chloestefantsova
Copy link
Contributor

I checked the part "Canonical syntax of types", in the green "after" column the lines range from 21737 to 21931. LGTM.

\end{dartCode}

\commentary{%
No \emph{least} upper bound exists for \code{A} and \code{B},
Copy link
Contributor

Choose a reason for hiding this comment

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

As I understand it, with the exception of a top type?

Copy link
Member Author

Choose a reason for hiding this comment

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

This particular sentence refers to the real, mathematical least upper bound in a set (Dart types) with an ordering relation (subtyping). The usage of 'least upper bound' in older versions of the spec is misleading, because it was never a least upper bound.

So we're looking for a type which is a supertype of both A and B, and it must be the least element among all the types which are supertypes of both A and B. It can't be I because we don't have I <: J; similarly it can't be J. But it also can't be a top type, because we don't have Top <: I (or J, or a bunch of other types).

So I think the claim is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

But it also can't be a top type, because we don't have Top <: I (or J, or a bunch of other types).

I don't think I understand this argument. Shouldn't we have I <: Top and J <: Top (in the reverse order) in order to claim Top as the upper bound for both I and J?

Additionally, I think declarations class I {} and class J {} imply class I extends Object {} respectively class J extends Object {}, which makes Object an upper bound for A and B.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, Object is an upper bound for each of those classes, but that makes no difference: The least upper bound (mathematically speaking) of a set S of elements in an ordered set {v1, .. vk} is an element v from S that satisfies (1) vj <: v, for all j, and (v1 <: other && .. && vk <: other) => v <: other. It's the latter part that fails, so Top and Object aren't 'least', they are just upper bounds.

@chloestefantsova
Copy link
Contributor

I've checked the part "Standard bounds", in the green "after" column the lines range from 21931 to 22759. LGTM with some comments.

@chloestefantsova
Copy link
Contributor

I've checked the part "Closures of types", in the green "after" column the lines range from 22759 to 22983. it LGTM.

@chloestefantsova
Copy link
Contributor

I checked the part "Types bounded by types", in the green "after" column the lines range from 22983 to 23015. LGTM with one small question.

@chloestefantsova
Copy link
Contributor

I checked the parts "Class building types", "Interface types", "Intersection types", "Never", "Null", "Type", "Function", "dynamic", in the green "after" column the lines range from 23015 to 24140. LGTM with some comments.

\LMHash{}%
A check of the form \code{$v$\,\,!=\,\,\NULL},
\code{\NULL\,\,!=\,\,$v$},
or \code{$v$\,\,\IS\,\,$T$}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it true for every type T? What about the case of T = S??

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the text to follow the null safety spec precisely about the rule such that we don't need to worry about unintended novelties.

However, v is T where the static type of v is T? is oddly specific, and it certainly doesn't cover the precise behavior of the CFE nor the analyzer.

So we would presumably need to find a way to describe the current behavior of the tools in more detail, such that they can continue to handle cases like X extends int? and still be in sync with the spec. I'll create an issue for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I made some changes to the text according to the response in #2258.

@chloestefantsova
Copy link
Contributor

I checked the part "Type inference", in the green "after" column the lines range from 24140 to 24613. LGTM with some minor questions.

Comment on lines 24795 to 24796
\item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
have the same canonical syntax, for $i \in 0 .. k$.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we ask for a weaker requirement: the bounds should be mutual subtypes or should be equal if all top types treated as being equal to each other and the bottom types treated as being equal to each other?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! The requirement should be 'mutual subtypes', and it's been updated now. I overlooked the change were === in the null safety feature spec was changed to mean 'mutual subtypes', and that's the reason why I kept the old text because === was still there. That shows the power of change propagation! ;-)

@chloestefantsova
Copy link
Contributor

I checked the part "Appendix. Algorithmic subtyping", in the green "after" column the lines range fro 24613 to 24847. LGTM with some question. That concludes my initial pass over the PR.

Copy link
Member Author

@eernstg eernstg left a comment

Choose a reason for hiding this comment

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

Review response.

specification/dartLangSpec.tex Show resolved Hide resolved
specification/dartLangSpec.tex Show resolved Hide resolved
specification/dartLangSpec.tex Show resolved Hide resolved
specification/dartLangSpec.tex Outdated Show resolved Hide resolved
specification/dartLangSpec.tex Outdated Show resolved Hide resolved
\LMHash{}%
A check of the form \code{$v$\,\,!=\,\,\NULL},
\code{\NULL\,\,!=\,\,$v$},
or \code{$v$\,\,\IS\,\,$T$}
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the text to follow the null safety spec precisely about the rule such that we don't need to worry about unintended novelties.

However, v is T where the static type of v is T? is oddly specific, and it certainly doesn't cover the precise behavior of the CFE nor the analyzer.

So we would presumably need to find a way to describe the current behavior of the tools in more detail, such that they can continue to handle cases like X extends int? and still be in sync with the spec. I'll create an issue for that.

\LMHash{}%
A check of the form \code{$v$\,\,!=\,\,\NULL},
\code{\NULL\,\,!=\,\,$v$},
or \code{$v$\,\,\IS\,\,$T$}
Copy link
Member Author

Choose a reason for hiding this comment

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

\LMHash{}%
A check of the form \code{$v$\,\,!=\,\,\NULL},
\code{\NULL\,\,!=\,\,$v$},
or \code{$v$\,\,\IS\,\,$T$}
Copy link
Member Author

Choose a reason for hiding this comment

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

I made some changes to the text according to the response in #2258.

Comment on lines 24795 to 24796
\item $B_{0i}[Z_0/X_0, \ldots, Z_k/X_k]$ and $B_{1i}[Z_0/Y_0, \ldots, Z_k/Y_k]$
have the same canonical syntax, for $i \in 0 .. k$.
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! The requirement should be 'mutual subtypes', and it's been updated now. I overlooked the change were === in the null safety feature spec was changed to mean 'mutual subtypes', and that's the reason why I kept the old text because === was still there. That shows the power of change propagation! ;-)

specification/dartLangSpec.tex Show resolved Hide resolved
@eernstg
Copy link
Member Author

eernstg commented Jul 4, 2022

The PR was rebased on the current master, that is, 3e99947.

@eernstg eernstg mentioned this pull request Nov 2, 2022
@eernstg eernstg force-pushed the specify_null_safety_new_sections_dec21 branch from 6cd9296 to 66420dd Compare November 30, 2023 17:04
@eernstg eernstg force-pushed the specify_null_safety_new_sections_dec21 branch from 185037e to ddd09ec Compare December 18, 2023 13:49
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.

None yet

3 participants