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

Support parsing function attributes #336

Open
techs-sus opened this issue Dec 28, 2024 · 5 comments · May be fixed by #337
Open

Support parsing function attributes #336

techs-sus opened this issue Dec 28, 2024 · 5 comments · May be fixed by #337
Labels
enhancement New feature or request

Comments

@techs-sus
Copy link

image
https://docs.rs/full_moon/1.1.2/src/full_moon/ast/parsers.rs.html#2571

The typed code includes unions and intersections, and does not have any code which directly uses the new solver.
I am also not sure if this is darklua's fault or full_moon's fault.

@JohnnyMorganz
Copy link
Collaborator

Can you paste the code that is causing the crash?

@techs-sus
Copy link
Author

techs-sus commented Dec 28, 2024

Can you paste the code that is causing the crash?

This error was from a production repository with a non permissive license; however I was able to create a reproduction below:

--[[
1. Create a generic
2. @native function
3. cast return of @native function to typeof(fn())?
4. unreachable!()
]]

-- can also be type Message<T> = T
type Message<T> = {
	time: number,
	data: T
}

-- must be @native
@native
local function fn(keys: { [string]: string }?): { [string]: Secret | string } end

-- must death cast
local headers = (fn() :: typeof(fn())?)

@techs-sus
Copy link
Author

techs-sus commented Dec 29, 2024

Nevermind; you do not need a generic to trigger this: Message can also be Message; e.g.

type A = unknown
@native local function fn(k: { [string]: string }?): { [string]: Secret | string } end
fn(fn() :: typeof(fn())?)

In fact, all you need is this, and full_moon panics:

type A = unknown
@native function fn() end

@JohnnyMorganz
Copy link
Collaborator

I don't think full moon supports function attributes yet, which seems to be the main issue. Although i'm not sure why we end up panicking in that case

@JohnnyMorganz JohnnyMorganz changed the title Full moon crashes when parsing code with types Support parsing function attributes Dec 30, 2024
@JohnnyMorganz
Copy link
Collaborator

Will repurpose this issue to support parsing function attributes, which should in the end stop this particular crash. If we see the crash again, will make a separate issue for it

@JohnnyMorganz JohnnyMorganz linked a pull request Dec 30, 2024 that will close this issue
@JohnnyMorganz JohnnyMorganz added the enhancement New feature or request label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants