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

bugfix: require relative names in import{Wordy,Symboly}Id #5568

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

mitchellwrosen
Copy link
Member

Overview

This PR fixes #4536 by changing this from a runtime crash to a parse error:

use foo .bar

During implementation, I surveyed other uses of the combinator that parsed ".bar" here (where we want to only allow relative "bar"), and determined that none of them need to allow both absolute and relative names, so for consistency and simplicity, I switched them all to require relative names, even when an absolute name has a sensible interpretation (e.g. "namespace .blah")

The full list of now-disallowed absolute dots (also see transcript where all of these are captured):

use .foo bar
    ^

use foo .bar
        ^

namespace .foo
          ^

.test> foo = ...
^

test.> foo = ...
    ^ (lol)

Test coverage

PR includes transcript

@mitchellwrosen mitchellwrosen changed the title bugfix: require absolute names in import{Wordy,Symboly}Id bugfix: require relative names in import{Wordy,Symboly}Id Feb 4, 2025
@mitchellwrosen mitchellwrosen marked this pull request as ready for review February 4, 2025 16:54
Comment on lines +17 to +40
I got confused here:

3 | use Nat .+


I was surprised to find a '.' here.
I was expecting one of these instead:

* bang
* binding
* do
* false
* force
* handle
* if
* lambda
* let
* newline or semicolon
* pattern
* quote
* termLink
* true
* tuple
* typeLink
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note, I'm not sure which one of these it wants.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I know, the error messages are atrocious :|

Comment on lines 55 to 66
I was expecting something after the use keyword

3 | use .lib.builtin.Nat +

Here's a few examples of valid `use` statements:

use math sqrt Introduces `sqrt` as a local alias for
`math.sqrt`
use List :+ Introduces `:+` as a local alias for
`List.:+`.
use .foo bar.baz Introduces `bar.baz` as a local alias for
the absolute name `.foo.bar.baz`
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not want to allow absolute names for the first one? The example on line 65 suggests it as correct syntax.

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 don't see a problem with allowing absolute names in certain places, I can make that change. My instinct was to simplify everything down to relative names, but that could be wrong.

@aryairani
Copy link
Contributor

Tentatively approved and seems okay for now, but I could see wanting to distinguish with absolute names in use (initial arg) and namespace down the line. We should also check with @rlmark to see if this impacts docs/tutorials?

Can you also address the second message I commented on, that suggests the now-unsupported syntax?

@mitchellwrosen
Copy link
Member Author

Conclusion: will revert part of this to allow use .absolute relative again, & will separately investigate whether absolute names like that behave well (esp in the 'nested use' case)

@aryairani
Copy link
Contributor

For reference the current user docs on use clauses are here, but they don't specify the behavior.

@mitchellwrosen
Copy link
Member Author

Ok, this is ready to go. The macOS CI errors look superfluous:

Warning: Cache not found for keys: ucm-macos-13-d00e32704977400ad483a1565b6bcb120279a86d0995a956a662dd5c2ae99395
Error: Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ucm-macos-13-d00e32704977400ad483a1565b6bcb120279a86d0995a956a662dd5c2ae99395

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.

E261635 - use lib.base.data.List .flatMap crashes ucm
2 participants