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

parser error: unexpected token ?, expecting name #22736

Closed
enghitalo opened this issue Nov 2, 2024 · 0 comments · Fixed by #22738
Closed

parser error: unexpected token ?, expecting name #22736

enghitalo opened this issue Nov 2, 2024 · 0 comments · Fixed by #22738
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Comments

@enghitalo
Copy link
Contributor

enghitalo commented Nov 2, 2024

Describe the bug

wrong checking for option type

Reproduction Steps

module main

import json

fn func(arg ?string, val &int) ?int {
	println('hello from func')
	unsafe { *val = 2 }
	return 2
}

fn main() {

	mapa := {"json": func}
	dump(mapa)
	dump(typeof(mapa['json']).name)

	mapa2 := map[string]fn(?string, &int) ?int{}
	mapa2["json"] = func

	number := 0

	mapa["json"]('hola', &number)

	dump(number)
}

Expected Behavior

not error

Current Behavior

a.v:18:25: error: unexpected token `?`, expecting name
   16 |     dump(typeof(mapa['json']).name)
   17 | 
   18 |     mapa2 := map[string]fn(?string, &int) ?int{}
      |                            ^
   19 |     mapa2["json"] = func
   20 |

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.8 fc6e481

Environment details (OS name and version, etc.)

Linux

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Huly®: V_0.6-21183

@enghitalo enghitalo added the Bug This tag is applied to issues which reports bugs. label Nov 2, 2024
@enghitalo enghitalo changed the title checker error: function type checker error: unexpected token ?, expecting name Nov 2, 2024
@enghitalo enghitalo added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Nov 2, 2024
@felipensp felipensp added Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones). and removed Unit: Checker Bugs/feature requests, that are related to the type checker. labels Nov 2, 2024
@felipensp felipensp changed the title checker error: unexpected token ?, expecting name parser error: unexpected token ?, expecting name Nov 2, 2024
@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Nov 2, 2024
@felipensp felipensp self-assigned this Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants