Skip to content

Commit 36ec77f

Browse files
committed
Promote Char to String for inline-var type inference
1 parent 9386f96 commit 36ec77f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

compiler/pstatmnt.pas

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,8 +1903,11 @@ ((p.resultdef.typ=recorddef) or
19031903
begin
19041904
{ String literal constants get type array[0..n] of char
19051905
(cst_conststring). Promote to the default string type
1906-
so that comparisons and assignments behave as expected. }
1907-
if is_conststring_array(hdef) then
1906+
so that comparisons and assignments behave as expected.
1907+
Single char literals are also promoted to string so
1908+
that var s := 'x' behaves consistently with var s := 'xx'. }
1909+
if is_conststring_array(hdef) or
1910+
(not(nf_explicit in initexpr.flags) and is_char(hdef)) then
19081911
begin
19091912
if m_default_unicodestring in current_settings.modeswitches then
19101913
hdef := cunicodestringtype

0 commit comments

Comments
 (0)