diff --git a/.gitattributes b/.gitattributes index 1fb842a740..e9e1313032 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12967,6 +12967,7 @@ tests/webtbs/tw2305.pp svneol=native#text/plain tests/webtbs/tw2306.pp svneol=native#text/plain tests/webtbs/tw2307.pp svneol=native#text/plain tests/webtbs/tw2311.pp svneol=native#text/plain +tests/webtbs/tw23136.pp svneol=native#text/pascal tests/webtbs/tw2317.pp svneol=native#text/plain tests/webtbs/tw2318.pp svneol=native#text/plain tests/webtbs/tw23185.pp svneol=native#text/pascal diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 38fac6c871..6cfd8e53ff 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -2814,6 +2814,11 @@ implementation begin p1:=cstringconstnode.createpchar(ansistring2pchar(cstringpattern),length(cstringpattern)); consume(_CSTRING); + if token in postfixoperator_tokens then + begin + again:=true; + postfixoperators(p1,again,getaddr); + end; end; _CCHAR : @@ -2826,6 +2831,11 @@ implementation begin p1:=cstringconstnode.createunistr(patternw); consume(_CWSTRING); + if token in postfixoperator_tokens then + begin + again:=true; + postfixoperators(p1,again,getaddr); + end; end; _CWCHAR: @@ -2842,7 +2852,7 @@ implementation if try_to_consume(_LKLAMMER) then begin p1:=factor(true,false); - if token in [_CARET,_POINT,_LECKKLAMMER] then + if token in postfixoperator_tokens then begin again:=true; postfixoperators(p1,again,getaddr); @@ -2852,7 +2862,7 @@ implementation end else p1:=factor(true,false); - if token in [_CARET,_POINT,_LECKKLAMMER] then + if token in postfixoperator_tokens then begin again:=true; postfixoperators(p1,again,getaddr); @@ -2875,9 +2885,9 @@ implementation consume(_LKLAMMER); p1:=comp_expr(true,false); consume(_RKLAMMER); - { it's not a good solution } - { but (a+b)^ makes some problems } - if token in [_CARET,_POINT,_LECKKLAMMER] then + { it's not a good solution + but (a+b)^ makes some problems } + if token in postfixoperator_tokens then begin again:=true; postfixoperators(p1,again,getaddr); diff --git a/compiler/tokens.pas b/compiler/tokens.pas index 9503ced33b..18c14d959c 100644 --- a/compiler/tokens.pas +++ b/compiler/tokens.pas @@ -299,6 +299,8 @@ const tokenlenmin = 1; tokenlenmax = 18; + postfixoperator_tokens = [_CARET,_POINT,_LECKKLAMMER]; + { last operator which can be overloaded, the first_overloaded should be declared directly after NOTOKEN } first_overloaded = succ(NOTOKEN); diff --git a/tests/webtbs/tw23136.pp b/tests/webtbs/tw23136.pp new file mode 100644 index 0000000000..a3df4afdf9 --- /dev/null +++ b/tests/webtbs/tw23136.pp @@ -0,0 +1,14 @@ +var + ws:widestring; + s:string; +begin + s:='Aajsljaklsja'[1]; + if s<>'A' then + halt(1); + + ws:=#1234#134#312[1]; + if ws<>#1234 then + halt(1); + + writeln('ok'); +end.