Skip to content

source compatibility project violet fails with a compiler error #955

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

Open
eeckstein opened this issue Jul 26, 2024 · 7 comments
Open

source compatibility project violet fails with a compiler error #955

eeckstein opened this issue Jul 26, 2024 · 7 comments
Labels

Comments

@eeckstein
Copy link
Contributor

Description

/build/swift-source-compat-suite/project_cache/violet/Sources/Compiler/Implementation/CompilerImpl+Expr.swift:14:31: error: 'Expression' is ambiguous for type lookup in this context
 12 | extension CompilerImpl {
 13 | 
 14 |   internal func visit(_ node: Expression) throws {
    |                               `- error: 'Expression' is ambiguous for type lookup in this context
 15 |     self.setAppendLocation(node)
 16 |     try node.accept(self)

Reproduction

builds:
https://ci.swift.org/job/swift-6.0-source-compat-suite-debug-ubuntu-2004/121/
https://ci.swift.org/job/swift-6.0-source-compat-suite-ubuntu-2004/121/
https://ci.swift.org/job/swift-source-compat-suite-debug-ubuntu-2004/499/
https://ci.swift.org/job/swift-source-compat-suite-ubuntu-2004/599/

log: https://ci.swift.org/job/swift-6.0-source-compat-suite-debug-ubuntu-2004/121/artifact/build/swift-source-compat-suite/FAIL_violet_5.3_BuildSwiftPackage.log

Expected behavior

should build fine

Environment

CI

Additional information

No response

@eeckstein eeckstein added the bug label Jul 26, 2024
@AnthonyLatsis
Copy link
Contributor

AnthonyLatsis commented Jul 26, 2024

Could this error actually be legit due to https://forums.swift.org/t/review-sf-0006-expression-macro-and-type/70211? Now there are two distinct extramodular Expression decls visible in this file — one from import Foundation and the other from import VioletParser.

@jmschonfeld
Copy link

Yes @AnthonyLatsis I believe you're correct. I think the module that imports both Foundation and VioletParser will need to be updated to disambiguate between the two types (either via fully qualified names, or via a typealias)

@AnthonyLatsis
Copy link
Contributor

AnthonyLatsis commented Aug 13, 2024

@xedin Since by all appearances this is not a compiler issue, could you please transfer it to the compat suite?

@hborla hborla transferred this issue from swiftlang/swift Oct 11, 2024
@justice-adams-apple
Copy link
Collaborator

Hi @LiarPrincess , it appears the source compatibility suite has discovered an issue building violet.

This will likely be uncovered in the next SDK update on our CI. Would you be interested in updating the violet source to account for this? If you find there is no longer any value in testing violet builds nightly, please let me know and I can remove it from the source compatability suite

@LiarPrincess
Copy link
Contributor

LiarPrincess commented Feb 11, 2025

Just a PR with an updated tag will suffice?

@justice-adams-apple
Copy link
Collaborator

justice-adams-apple commented Feb 11, 2025

Just a PR with an updated tag will suffice?

Yep, or you can just send me an updated revision and I can open a PR quick and tag you for review

@LiarPrincess
Copy link
Contributor

I created a PR (link above).

There may be a defect in the ambiguity resolution. Tested on: swift-6.1-DEVELOPMENT-SNAPSHOT-2025-02-10-a-ubuntu24.04.

This will NOT compile:

protocol Proto {}

extension Proto {
  typealias Expression = Int
}

class X: Proto {
  // 🔴 main.swift:60:15: error: reference to generic type 'Expression' requires arguments in <...>
  // FoundationEssentials.Expression:2:15: note: generic type 'Expression' declared here
  func foo(n: Expression) {}
}

This will compile:

class Base {
  typealias Expression = Int
}
class Child: Base {
  // 🟢 Works.
  func foo(n: Expression) {}
}

In other words:

  • types coming from the class inheritance are recognized as a part of the type
  • types coming from the protocol conformance are skipped

I think that both of them should be recognized as a part of the type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants