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-4348] Literal String concatenation does not work #46927

Closed
aschwaighofer opened this issue Mar 24, 2017 · 3 comments
Closed

[SR-4348] Literal String concatenation does not work #46927

aschwaighofer opened this issue Mar 24, 2017 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@aschwaighofer
Copy link
Member

Previous ID SR-4348
Radar None
Original Reporter @aschwaighofer
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @swiftix
Priority Medium

md5: 0ac4980d3e4dd58534dd5827bcd1c36e

Issue Description:

This string does not get concatenated:

$ cat testStr.swift
let sample = "a" + "გ" + "x"

$ /Library/Developer/Toolchains/swift-LOCAL-2017-03-22-a-base.xctoolchain/usr/bin/swiftc -Onone -emit-sil testStr.swift

bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
alloc_global @_T07testStr6sampleSSv, loc "testStr.swift":1:5, scope 1 // id: %2
%3 = global_addr @_T07testStr6sampleSSv : $*String, loc "testStr.swift":1:5, scope 1 // user: %28
// function_ref static String.+ infix(String, String) -> String
%4 = function_ref @_T0SS1poiS2S_SStFZ : $@convention(method) (@owned String, @owned String, @thin String.Type) -> @owned String, loc "testStr.swift":1:26, scope 1 // user: %27
%5 = metatype $@thin String.Type, loc "testStr.swift":1:26, scope 1 // user: %27
// function_ref static String.+ infix(String, String) -> String
%6 = function_ref @_T0SS1poiS2S_SStFZ : $@convention(method) (@owned String, @owned String, @thin String.Type) -> @owned String, loc "testStr.swift":1:18, scope 1 // user: %20
%7 = metatype $@thin String.Type, loc "testStr.swift":1:18, scope 1 // user: %20
%8 = string_literal utf8 "a", loc "testStr.swift":1:14, scope 1 // user: %13
%9 = integer_literal $Builtin.Word, 1, loc "testStr.swift":1:14, scope 1 // user: %13
%10 = integer_literal $Builtin.Int1, -1, loc "testStr.swift":1:14, scope 1 // user: %13
%11 = metatype $@thin String.Type, loc "testStr.swift":1:14, scope 1 // user: %13
// function_ref String.init(_builtinStringLiteral : Builtin.RawPointer, utf8CodeUnitCount : Builtin.Word, isASCII : Builtin.Int1) -> String
%12 = function_ref @_T0S2SBp21_builtinStringLiteral_Bw17utf8CodeUnitCountBi1_7isASCIItcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String, loc "testStr.swift":1:14, scope 1 // user: %13
%13 = apply %12(%8, %9, %10, %11) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String, loc "testStr.swift":1:14, scope 1 // user: %20
%14 = string_literal utf16 "გ", loc "testStr.swift":1:20, scope 1 // user: %19
%15 = integer_literal $Builtin.Word, 1, loc "testStr.swift":1:20, scope 1 // user: %19
%16 = integer_literal $Builtin.Int1, 0, loc "testStr.swift":1:20, scope 1
%17 = metatype $@thin String.Type, loc "testStr.swift":1:20, scope 1 // user: %19
// function_ref String.init(_builtinUTF16StringLiteral : Builtin.RawPointer, utf16CodeUnitCount : Builtin.Word) -> String
%18 = function_ref @_T0S2SBp26_builtinUTF16StringLiteral_Bw18utf16CodeUnitCounttcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, @thin String.Type) -> @owned String, loc "testStr.swift":1:20, scope 1 // user: %19
%19 = apply %18(%14, %15, %17) : $@convention(method) (Builtin.RawPointer, Builtin.Word, @thin String.Type) -> @owned String, loc "testStr.swift":1:20, scope 1 // user: %20
%20 = apply %6(%13, %19, %7) : $@convention(method) (@owned String, @owned String, @thin String.Type) -> @owned String, loc "testStr.swift":1:18, scope 1 // user: %27
%21 = string_literal utf8 "x", loc "testStr.swift":1:28, scope 1 // user: %26
%22 = integer_literal $Builtin.Word, 1, loc "testStr.swift":1:28, scope 1 // user: %26
%23 = integer_literal $Builtin.Int1, -1, loc "testStr.swift":1:28, scope 1 // user: %26
%24 = metatype $@thin String.Type, loc "testStr.swift":1:28, scope 1 // user: %26
// function_ref String.init(_builtinStringLiteral : Builtin.RawPointer, utf8CodeUnitCount : Builtin.Word, isASCII : Builtin.Int1) -> String
%25 = function_ref @_T0S2SBp21_builtinStringLiteral_Bw17utf8CodeUnitCountBi1_7isASCIItcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String, loc "testStr.swift":1:28, scope 1 // user: %26
%26 = apply %25(%21, %22, %23, %24) : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin String.Type) -> @owned String, loc "testStr.swift":1:28, scope 1 // user: %27
%27 = apply %4(%20, %26, %5) : $@convention(method) (@owned String, @owned String, @thin String.Type) -> @owned String, loc "testStr.swift":1:26, scope 1 // user: %28
store %27 to %3 : $*String, loc "testStr.swift":1:26, scope 1 // id: %28
%29 = integer_literal $Builtin.Int32, 0, scope 1 // user: %30
%30 = struct $Int32 (%29 : $Builtin.Int32), scope 1 // user: %31
return %30 : $Int32, scope 1 // id: %31
} // end sil function 'main'

@aschwaighofer
Copy link
Member Author

Roman did you work on this once? Can you take a look?

@swiftix
Copy link
Mannequin

swiftix mannequin commented Mar 25, 2017

I know the reason. The fix is in progress.

@swiftix
Copy link
Mannequin

swiftix mannequin commented Mar 25, 2017

Committed on swift/master as cfc216c

@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.
Projects
None yet
Development

No branches or pull requests

1 participant