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-13070] AST verification failure regarding @differentiable attribute: "checked decl cannot have error type" #55516

Open
dan-zheng opened this issue Jun 24, 2020 · 1 comment
Assignees
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-13070
Radar rdar://problem/74094401
Original Reporter @dan-zheng
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AutoDiff, CompilerCrash
Assignee @rxwei
Priority Medium

md5: 0b10d7cbd6875867fcb054de325ea6ee

relates to:

  • SR-11838 Cycle involving implicit initializers and witness resolution

Issue Description:

import _Differentiation

// NOTE: No crash if `class` is changed to `struct`.
class Class: Differentiable {
  // NOTE: No crash if `@differentiable` attribute is removed.
  @differentiable
  var x: Float = 10

  var y: NonExistentType = 30
}
$ swiftc error.swift
error.swift:11:3: warning: synthesis of the 'Differentiable.move(along:)' requirement for 'Class' requires 'wrappedValue' in property wrapper 'Wrapper' to be mutable; add an explicit '@noDerivative' attribute
  @differentiable
  ^
  @noDerivative
checked decl cannot have error type
(accessor_decl implicit range=[error.swift:14:7 - line:14:7] 'anonname=0x7fd7258992a0' interface type='(Class) -> () -> <<error type>>' access=internal get_for=y
  (parameter "self" type='Class' interface type='Class')
  (parameter_list)
  (brace_stmt implicit range=[error.swift:14:7 - line:14:7]
    (return_stmt implicit
      (member_ref_expr implicit type='<<error type>>' decl=error.(file).Class.y@error.swift:14:7 direct_to_storage
        (declref_expr implicit type='Class' decl=error.(file).Class.<anonymous>.self@error.swift:14:7 function_ref=unapplied)))))
Stack dump:
0.  Program arguments: /Users/danielzheng/swift-tf/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file error.swift -target x86_64-apple-darwin19.4.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -target-sdk-version 10.15.4 -module-name error -o /var/folders/m_/6f7q8zfs3n9fr0c_4gy8840m00hc_q/T/error-df9d65.o
1.  Swift version 5.3-dev (LLVM 537023d5f0, Swift f2b25f7355)
2.  While walking into decl 'Class' (at error.swift:9:1)
3.  While verifying AccessorDecl getter for y (at error.swift:14:7)
4.  While verifying FuncDecl getter for y (at error.swift:14:7)
5.  While verifying AbstractFunctionDecl getter for y (at error.swift:14:7)
0  swift                    0x000000010fd2f218 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x000000010fd2e198 llvm::sys::RunSignalHandlers() + 248
2  swift                    0x000000010fd2f80d SignalHandler(int) + 285
3  libsystem_platform.dylib 0x00007fff6a3e15fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338733709856
5  libsystem_c.dylib        0x00007fff6a2b7808 abort + 120
6  swift                    0x00000001101f41b0 (anonymous namespace)::Verifier::verifyChecked(swift::VarDecl*) (.cold.1) + 0
7  swift                    0x000000010c78efae (anonymous namespace)::Verifier::verifyChecked(swift::ValueDecl*) + 174
8  swift                    0x000000010c78fc08 (anonymous namespace)::Verifier::verifyChecked(swift::AbstractFunctionDecl*) + 888
9  swift                    0x000000010c78fdda (anonymous namespace)::Verifier::verifyChecked(swift::FuncDecl*) + 314

What's expected is a "type not found in scope" diagnostic:

error.swift:9:10: error: cannot find type 'NonExistentType' in scope
  var y: NonExistentType = 30
         ^~~~~~~~~~~~~~~
@rxwei
Copy link
Member

rxwei commented Feb 8, 2021

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

3 participants