Skip to content

Commit 0bf8fd2

Browse files
authored
Merge pull request #543 from Carltoffel/fix-string-concat
Fix string concat
2 parents 65b74f8 + e24a925 commit 0bf8fd2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/stdlib_string_type.fypp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ contains
10821082
type(string_type), intent(in) :: rhs
10831083
type(string_type) :: string
10841084

1085-
string%raw = maybe(rhs) // maybe(lhs)
1085+
string%raw = maybe(lhs) // maybe(rhs)
10861086

10871087
end function concat_string_string
10881088

src/tests/string/test_string_operator.f90

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ subroutine test_ne
9999
end subroutine test_ne
100100

101101
subroutine test_concat
102-
type(string_type) :: string
103-
104-
string = "Hello, "
105-
string = string // "World!"
106-
call check(len(string) == 13)
102+
type(string_type) :: a, b
103+
104+
a = "a"
105+
b = "b"
106+
call check( "a" // b == "ab" )
107+
call check( a // "b" == "ab" )
108+
call check( a // b == "ab" )
109+
call check( a // "" == "a" )
110+
call check( "" // b == "b" )
107111
end subroutine test_concat
108112

109113
end module test_string_operator

0 commit comments

Comments
 (0)