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-14296] Unexpected error while dump-parse on swift file #56655

Closed
LucianoPAlmeida opened this issue Mar 3, 2021 · 6 comments
Closed

[SR-14296] Unexpected error while dump-parse on swift file #56655

LucianoPAlmeida opened this issue Mar 3, 2021 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@LucianoPAlmeida
Copy link
Collaborator

Previous ID SR-14296
Radar rdar://problem/75032460
Original Reporter @LucianoPAlmeida
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Xcode 12.4 Swift 5.3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 178cc12bc0a78e3983601e39200f1d01

Issue Description:

Given a swift file with the following code

public extension Int {
    var i: Int { 0 }
    
    func times2() -> Int { self * self }

    static func afunction() {}

    static func afunction1() {}
}

extension Int {
    public func times3() -> Int { self * self }

    static public func afunction2() {}
}

When trying to dump the pre-typechecked AST with `swiftc -dump-parse syntax.swift` , I'm seeing a diagnostics that to me it shouldn't be there.

syntax.swift:11:11: error: cannot find type 'Int' in scope
extension Int {
          ^~~
<<error type>>

Here is the full dump

In text

(source_file "syntax.swift"
  (extension_decl range=[syntax.swift:1:8 - line:9:1] syntax.swift:1:18: error: cannot find type 'Int' in scope
public extension Int {
                 ^~~
<<error type>>
    (pattern_binding_decl range=[syntax.swift:2:5 - line:2:20]
      (pattern_typed
        (pattern_named 'i')
        (type_ident
          (component id='Int' bind=none))))
    (var_decl range=[syntax.swift:2:9 - line:2:9] "i" type='<null type>' readImpl=getter immutable
      (accessor_decl range=[syntax.swift:2:16 - line:2:20] 'anonname=0x7ff004841ad0' get_for=i
        (parameter "self")
        (parameter_list)
        (integer_literal_expr type='<null>' value=0 builtin_initializer=**NULL** initializer=**NULL**)))
    (func_decl range=[syntax.swift:4:5 - line:4:40] "times2()"
      (parameter "self")
      (parameter_list range=[syntax.swift:4:16 - line:4:17])
      (result
        (type_ident
          (component id='Int' bind=none)))
      (sequence_expr type='<null>'
        (declref_expr type='<null>' decl=syntax.(file). extension.times2().self@syntax.swift:4:10 function_ref=unapplied)
        (unresolved_decl_ref_expr type='<null>' name=* function_ref=unapplied)
        (declref_expr type='<null>' decl=syntax.(file). extension.times2().self@syntax.swift:4:10 function_ref=unapplied)))
    (func_decl range=[syntax.swift:6:5 - line:6:30] "afunction()" type
      (parameter "self")
      (parameter_list range=[syntax.swift:6:26 - line:6:27])
      (brace_stmt range=[syntax.swift:6:29 - line:6:30]))
    (func_decl range=[syntax.swift:8:5 - line:8:31] "afunction1()" type
      (parameter "self")
      (parameter_list range=[syntax.swift:8:27 - line:8:28])
      (brace_stmt range=[syntax.swift:8:30 - line:8:31])))
  (extension_decl range=[syntax.swift:11:1 - line:15:1] syntax.swift:11:11: error: cannot find type 'Int' in scope
extension Int {
          ^~~
<<error type>>
    (func_decl range=[syntax.swift:12:12 - line:12:47] "times3()"
      (parameter "self")
      (parameter_list range=[syntax.swift:12:23 - line:12:24])
      (result
        (type_ident
          (component id='Int' bind=none)))
      (sequence_expr type='<null>'
        (declref_expr type='<null>' decl=syntax.(file). extension.times3().self@syntax.swift:12:17 function_ref=unapplied)
        (unresolved_decl_ref_expr type='<null>' name=* function_ref=unapplied)
        (declref_expr type='<null>' decl=syntax.(file). extension.times3().self@syntax.swift:12:17 function_ref=unapplied)))
    (func_decl range=[syntax.swift:14:5 - line:14:38] "afunction2()" type
      (parameter "self")
      (parameter_list range=[syntax.swift:14:34 - line:14:35])
      (brace_stmt range=[syntax.swift:14:37 - line:14:38]))))
@typesanitizer
Copy link

@swift-ci create

@bnbarham
Copy link
Contributor

bnbarham commented Mar 9, 2021

I can reproduce in 12.4 but not on main. @LucianoPAlmeida would you be able to verify it's fixed in the latest toolchain?

@LucianoPAlmeida
Copy link
Collaborator Author

Sure, I'll try on main. Thanks for looking

@LucianoPAlmeida
Copy link
Collaborator Author

On compiler explorer main is still reproducible

But I have a near main branch built, will check there to make sure

@LucianoPAlmeida
Copy link
Collaborator Author

Just verified on a near main branch using lit, seems fixed! Thanks for taking a look @bnbarham =]

@bnbarham
Copy link
Contributor

bnbarham commented Mar 9, 2021

No problem, thanks for verifying so quickly!

@swift-ci swift-ci transferred this issue from apple/swift-issues 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. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants