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

[SR-12795] Can't call const C++ method on let constant #55240

Closed
swift-ci opened this issue May 12, 2020 · 2 comments
Closed

[SR-12795] Can't call const C++ method on let constant #55240

swift-ci opened this issue May 12, 2020 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself good first issue Good for newcomers

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12795
Radar None
Original Reporter MForster (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CxxInterop, StarterBug
Assignee @egorzhdan
Priority Medium

md5: 44f47dbedbd9065def121bac64cc954f

duplicates:

  • SR-12749 [C++] Import C++ const methods as non-mutating

Issue Description:

In C++:

struct S {
  int getConstant() const { return 42; }
};

In Swift:

let x = S()
x.getConstant()

Error Message:

foo.swift:6:3: error: cannot use mutating member on immutable value: 'x' is a 'let' constant
x.getConstant()
~ ^
foo.swift:5:1: note: change 'let' to 'var' to make it mutable
let x = S()
^~~
var
@egorzhdan
Copy link
Collaborator

PR: #38618

@zoecarver
Copy link
Collaborator

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@zoecarver zoecarver added c++ interop Feature: Interoperability with C++ and removed CxxInterop labels Apr 25, 2022
This issue was closed.
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. c++ interop Feature: Interoperability with C++ compiler The Swift compiler in itself good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants