tw35590.pp 853 B

1234567891011121314151617181920212223242526272829303132333435
  1. {$mode objfpc}
  2. {$inline on}
  3. {$h+}
  4. program project1;
  5. function sLow: integer; inline;
  6. begin result := 1; end;
  7. function sHigh( const s: string): integer; inline;
  8. begin result := Length(s); end;
  9. procedure insert2( const substr: string; var s: string; index: integer);
  10. begin insert( substr, s, index); end;
  11. function replaceChars(const s, subStr: string): string;
  12. var i: integer;
  13. begin
  14. result := s;
  15. // ok with sHigh(s) or with non-inlined sHigh(result)
  16. for i := sHigh(result) downto sLow() do begin
  17. delete( result, i, 1);
  18. insert2( subStr, result, i); // ok with (unwrapped) insert( subStr, result, i)
  19. end;
  20. end; // Error: Internal error 200405231
  21. procedure test1;
  22. var s, newChar, r: ansistring;
  23. begin
  24. s := 'old'; newChar := 'Replace';
  25. r := replaceChars( s, newChar);
  26. end;
  27. begin
  28. test1;
  29. end.