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

Experiment: restrict allowed trees in annotations #21840

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mbovel
Copy link
Member

@mbovel mbovel commented Oct 23, 2024

Non-basic trees in type annotations currently cause compiler crashes. This experiment introduces restrictions on the trees allowed in annotations, similar to those in Java (§9.7. Annotations).

@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 009c2a4 to a1d0910 Compare October 23, 2024 18:35
@mbovel mbovel changed the title Experiment: restrict allowed trees in type annotations Experiment: restrict allowed trees in annotations Oct 24, 2024
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch 3 times, most recently from f2779a0 to 5455c5d Compare November 5, 2024 22:08
@mbovel
Copy link
Member Author

mbovel commented Nov 6, 2024

def compose1[A, B, C](f: A => B, g: B => C): A ->{f, g} C =
z => g(f(z))

In this test, Ident(f) has type Function1[A, A], and is therefore not considered valid with the current rules. Why doesn't f have a singleton type?

f also does not have a symbol.

@mbovel
Copy link
Member Author

mbovel commented Nov 6, 2024

val value: Expr[Int] = '{ 42 }
'{ new Quoted[T @Annot($value)] }

Another question is what to do with splices, such as in the example above. Type splices are not valid anyway, so it might be okay to also refuse splices in type annotations?

@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 5455c5d to 2cc6ea4 Compare November 6, 2024 13:58
@mbovel

This comment was marked as resolved.

mbovel and others added 2 commits November 13, 2024 17:01
Throw away erroneous trees to avoid unpickling issues in best-effort mode.

Co-Authored-By: Kacper Korban <[email protected]>
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 2cc6ea4 to d9ba132 Compare November 13, 2024 16:02
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch 2 times, most recently from a7bd23b to 6cc02f0 Compare November 22, 2024 21:55
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 6cc02f0 to 040ec39 Compare November 23, 2024 00:07
@mbovel mbovel force-pushed the mb/restrict-type-annotations branch from 3a897c7 to dd3b668 Compare November 23, 2024 19:24
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