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

Proposal to refactor Span. #795

Open
otrho opened this issue Feb 14, 2022 · 0 comments
Open

Proposal to refactor Span. #795

otrho opened this issue Feb 14, 2022 · 0 comments
Labels
compiler General compiler. Should eventually become more specific as the issue is triaged enhancement New feature or request

Comments

@otrho
Copy link
Contributor

otrho commented Feb 14, 2022

Why Span?

  • For error reporting.
  • For source mapping.

What does Span look like now?

  • A Pest Span:
    • Shared source string.
    • Start and end indices into string.
  • An optional source file path.

What is this structure currently good for?

  • Error reporting. Everything is very handy. Even without the path.

Bad for?

  • Source mapping:
    • Requires path, and for start and end to be file offsets.
  • IR:
    • Not every error producing value has a known span.
    • (De)serialisation prefers path + indices, does not want to (de)serialise source strings.

A solution?

  • Remove Pest span and make the path mandatory:
    • Source mapping is happy.
    • If no path is applicable then one cannot create a Span, so the whole Span must then be Option, or we have an 'official' or 'default' empty/null Span.
    • IR (de)serialisation is simplified.
  • Make spans optional for error reporting:
    • IR can create errors without Spans. Note, this would hopefully be pretty rare. The IR would try very hard to provide a Span when asked but can't guarantee a Span, and therefore must be optional.
    • Source mapping doesn't care.
@otrho otrho added enhancement New feature or request compiler General compiler. Should eventually become more specific as the issue is triaged labels Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler General compiler. Should eventually become more specific as the issue is triaged enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

1 participant