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

vfmt removes selective import of interface when used only in implements clause #22200

Closed
Krotki opened this issue Sep 11, 2024 · 3 comments · Fixed by #22209 or #22218
Closed

vfmt removes selective import of interface when used only in implements clause #22200

Krotki opened this issue Sep 11, 2024 · 3 comments · Fixed by #22209 or #22218
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@Krotki
Copy link
Contributor

Krotki commented Sep 11, 2024

Describe the bug

V fmt removes selective imports of an interface when a given interface is used only in implements clause.

The compiler will not complain after formatting, but I'm puzzled how compiler knows where the symbol 'Visitor' comes from as it does not contain qualifier nor such symbol exists in local scope. Might be that this is not checked.

Reproduction Steps

Given:

import v.ast.walker { Visitor }
import v.ast {Node}

struct Walker implements Visitor  {
	aaa  string
}

fn (mut n Walker) visit(node &Node) ! {
	panic('not implemented')
}

Run v fmt on it

Expected Behavior

Selective import not removed.

Current Behavior

First line will be transformed to import v.ast.walker.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.7 79bedff

Environment details (OS name and version, etc.)

V full version: V 0.4.7 a7db095.79bedff
OS: linux, Linux Mint 21.3
Processor: 20 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i9-12900H

getwd: /home/jakub/repos/V-ConsoleTest
vexe: /home/jakub/programy/v/v
vexe mtime: 2024-09-11 21:12:09

vroot: OK, value: /home/jakub/programy/v
VMODULES: OK, value: /home/jakub/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.34.1
Git vroot status: weekly.2024.36-42-g79bedff1
.git/config present: true

CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
thirdparty/tcc status: thirdparty-linux-amd64 a0799a5

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.

@Krotki Krotki added the Bug This tag is applied to issues which reports bugs. label Sep 11, 2024
@Krotki
Copy link
Contributor Author

Krotki commented Sep 12, 2024

Actually there might be 2 separate issues.

  1. v fmt does not see usage of the type used in implements clause
  2. compiler does not check if a given interface exists

For the second one if I do:

struct Walker implements Abcdef {
	aaa string
}

Compiler does not complain that Abcdef type is not recognized, but continues with normal compilation.

@medvednikov
Copy link
Member

Will fix today.

@spytheman
Copy link
Member

I've reopened it, since #22209 fixes only the formatting issue, not the interface existence one.

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.
Projects
None yet
3 participants