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

Noncopyable type the compiler can't verify #78080

Open
TeamPuzel opened this issue Dec 10, 2024 · 0 comments
Open

Noncopyable type the compiler can't verify #78080

TeamPuzel opened this issue Dec 10, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@TeamPuzel
Copy link

Description

The compiler told me this is a bug and to report it, so here it is

Reproduction

@preconcurrency import GLAD

@_marker
public protocol Uniform {}

public struct Shader: ~Copyable {
    private let id: GLuint
    private var uniformLocations: [String: GLint] = [:]
    private var vertex: String
    private var fragment: String
    
    private static func compile(kind: SourceKind, source: String) -> GLuint { ... }
    public init(vertex: String, fragment: String) throws(CompileError) { ... }
    deinit { glad_glDeleteProgram(self.id) }
    func bind() { glad_glUseProgram(self.id) }
    
    public subscript<T: Uniform>(uniform: String, of type: T.Type) -> T {
        get {
            fatalError()
        }
        set { // The error happens here --------------------------------------------------
            self.uniformLocations[
                uniform,
                default: {
                    uniform.utf8CString.withUnsafeBufferPointer { buffer in
                        glad_glGetUniformLocation(self.id, buffer.baseAddress)
                    }
                }()
            ]
        }
    }
    
    public enum SourceKind: Sendable { case vertex, fragment }
    
    public enum CompileError: Swift.Error {
        case couldNotValidateShader(message: String, vertex: String, fragment: String)
        case couldNotCompileShader(message: String, kind: SourceKind, source: String)
    }
}

Expected behavior

N/A

Environment

Apple Swift version 6.2-dev (LLVM 4930d5a55e7728b, Swift ec5bee8)
Target: arm64-apple-macosx15.0

Additional information

No response

@TeamPuzel TeamPuzel added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant