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

bug: Use of generic within implicit parselet fails to compile #130

Open
phorward opened this issue Dec 29, 2023 · 2 comments
Open

bug: Use of generic within implicit parselet fails to compile #130

phorward opened this issue Dec 29, 2023 · 2 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@phorward
Copy link
Member

phorward commented Dec 29, 2023

This little program

Test : @<T: 'x'> {
    Pos<(T | 'X')>
}

Test

fails to compile:

thread 'main' panicked at src/compiler/iml/imlvalue.rs:355:52:
IndexMap: key not found
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The problem is that (T | 'X') is made into an implicit parselet, which references generic T, but T is not a generic of that implicit parselet. Unfortuntately, this issue is a conceptual problem with the current compiler. It cannot be bypassed right now.

@phorward phorward added the bug Something isn't working label Dec 29, 2023
@phorward phorward self-assigned this Dec 29, 2023
@phorward
Copy link
Member Author

The problem can be seen as part of #128

@phorward phorward changed the title bug: Use of generic within anonymous parselet fails to compile bug: Use of generic within implicit parselet fails to compile Jan 18, 2024
phorward added a commit to phorward/tokay that referenced this issue Jan 18, 2024
Started with until.tok draft.
Currently not working due tokay-lang#130.
@phorward phorward pinned this issue May 23, 2024
@phorward
Copy link
Member Author

phorward commented Oct 1, 2024

Here are further examples that all produce invalid results. It is a design issue in the compiler's current ImlParselet concept, which requires a deeper and stable rewrite. Tested with Tokay v0.6.6 (a245f24)

Fails with thread 'main' panicked at src/compiler/iml/imlparselet.rs:244:63: called Option::unwrap() on a None value

Double : @<U> {
    print("Double   ->", *U)
    U U
}

Single : @<V> {
    print("Single   ->", *V)
    V | 'X'
}

Test : @<T: 'x'> {
    print("Test     ->", *T)
    Double<Single<T>>  print("YES")
}

This version where all generics are named T "runs", but it produces invalid results and is not the wanted behavior.

Double : @<T> {
    print("Double   ->", *T)
    T T
}

Single : @<T> {
    print("Single   ->", *T)
    T | 'X'
}

Test : @<T: 'x'> {
    print("Test     ->", *T)
    Double<Single<T>>  print("YES")
}

Test

So this is an example that must work in both cases and should accept the input xx, XX, xX and Xx with YES printed.

Unfortunately I currently don't have the time to face this, but I will do ASAP and when I have an idea for an implementation. Help wanted!

@phorward phorward added the help wanted Extra attention is needed label Oct 1, 2024
@phorward phorward added this to the v0.7 milestone Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant