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: parse string and array typ idx of ScopeVar and Ident #21523

Merged
merged 3 commits into from
May 19, 2024

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented May 18, 2024

Will extend capabilities and e.g. allow to finish #21421.

Current types in scope and info

  scope: &# 3 - 311
* var: foo - ast.Type(0x0 = 0) # e.g. string type
* var: baz - ast.Type(0x0 = 0) # e.g. array type
# ...
info: ast.IdentInfo(ast.IdentVar{
    typ: ast.Type(0x0 = 0)
    share: mut
    is_mut: false
    is_static: false
    is_volatile: false
    is_option: false
})
# ...

Updated:

  scope: &# 3 - 311
* var: foo - ast.Type(0x15 = 21)
* var: baz - ast.Type(0x17 = 23)
# ...
info: ast.IdentInfo(ast.IdentVar{
    typ: ast.Type(0x17 = 23)
    share: mut
    is_mut: false
    is_static: false
    is_volatile: false
    is_option: false
})
# ...

The parsing can be limited to p.pref.is_vet and p.pref.is_fmt if it is preferred.

@ttytm ttytm changed the title parser: parse typ idx of ScopeVar and Ident parser: parse string and array typ idx of ScopeVar and Ident May 18, 2024
@spytheman
Copy link
Member

This is an improvement, but note that the problem, is that parsing is done on individual .v files, while the type information requires a pass over the whole module AST in the general case.
Consider, what will v vet do for a file that uses a constant or a symbol, defined in the same module, but in another .v file - its .typ will be still 0 ...

@ttytm
Copy link
Member Author

ttytm commented May 18, 2024

Right, for the global scope this won't work.

Also, this makes me remember something.

Some months ago, I started working on parsing all files of a module to at least get all declarations into global scope to fix the modprefix.constant formatting for files in a module that use a constant declared in another file of the module. I made some good progress but didn't follow through with it. I'll try to dig these changes out again and finish them. Unfortunately, my time is more limited currently.

@spytheman spytheman merged commit 1f7c91e into vlang:master May 19, 2024
69 checks passed
@ttytm ttytm deleted the parser/parse-var-types branch May 19, 2024 08:01
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.

None yet

2 participants