diff --git a/.gitattributes b/.gitattributes index 29c7e4eaef..1e8cbc7380 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9493,6 +9493,7 @@ tests/webtbf/tw14849.pp svneol=native#text/plain tests/webtbf/tw14929a.pp svneol=native#text/plain tests/webtbf/tw14929b.pp svneol=native#text/plain tests/webtbf/tw14946.pp svneol=native#text/plain +tests/webtbf/tw15288.pp svneol=native#text/plain tests/webtbf/tw1599.pp svneol=native#text/plain tests/webtbf/tw1599b.pp svneol=native#text/plain tests/webtbf/tw1633.pp svneol=native#text/plain diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index a8c1dcc12f..6968d91c8f 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -515,9 +515,11 @@ implementation stringdef : begin + if (p2.nodetype<>stringconstn) then + Message(parser_e_illegal_expression) { if we've already set elements which are constants } { throw an error } - if ((hdef=nil) and assigned(buildp)) or + else if ((hdef=nil) and assigned(buildp)) or not(is_char(hdef)) then CGMessage(type_e_typeconflict_in_set) else diff --git a/tests/webtbf/tw15288.pp b/tests/webtbf/tw15288.pp new file mode 100644 index 0000000000..ec5271a22b --- /dev/null +++ b/tests/webtbf/tw15288.pp @@ -0,0 +1,26 @@ +{ %fail } + +program setcrash; + +{$mode objfpc}{$H+} + +uses + Classes, SysUtils; + +var + AString: String='blabla'; + +procedure GetKey(var Key: Char); +begin + if Key in ['c', AString] then + writeln('OK'); +end; + +var + AKey: Char; +begin + AKey := 'c'; + GetKey(AKey); +end. + +