vfmt,parser: move mark used from vfmt to parser#25190
Conversation
|
Connected to Huly®: V_0.6-24305 |
|
Please don't merge it now. module main
import math { max }
fn max() {
}
fn main() {
mut max := 1
dump(max)
}
after module main
import math
fn max() {
}
fn main() {
mut max := 1
dump(max)
}
|
|
No, @kbkpbot For the program you posted, it should not remove the imported symbol name, and it does not on master. |
|
currently module main
import math { max, min }
fn main() {
}will remove unused imported symbols. And it also try to add missing os.dir()will output : import os
os.dir()imho, |
I agree completely. It should do only cosmetic changes, and at most updating old syntax to new one. It should not try to guess anything - that is a job, better done by other tools, that have more context. |
|
However, I think that changing it, is currently out of scope for this PR. |
The slowdown for macos is between 0.5%-1% (for short programs like hello world) and 2.2% (for v). |
The original
vfmtinternally handled the marking of usedimportsandsymbolsby itself through a "mark used" mechanism.This PR moves the corresponding functionality of
vfmtto theparsermodule.This eliminates the need for the "mark used" logic within
vfmt, makingimportstatement handling and future integration of$if { import xx }easier.The
vfmttests forvlibhave passed.