Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-02

Unexpected behaviour for With ... Do construct

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

I've hit a subtle issue whilst using the With ... Do construct in a program I am working on. I have isolated the behaviour to the following trivial unit:

Unit TestClasses;
Interface
Type
  TOtherClass = Class
  Public
    SomeValue: Boolean;
  End;
  TMainClass = Class
  Public
    FOtherClass: TOtherClass;
    Procedure DoSomething;
  End;
Implementation
Procedure TMainClass.DoSomething;
Var
  Test: Boolean;
Begin
// This compiles ok:
  Test := FOtherClass.SomeValue;
// This Fails to compile:
  With FOtherClass Do;
    Test := SomeValue;
End;
End.

The compilation halts with:

  TestClasses.pas(27,22) Error: Identifier not found "SomeValue"

I am working off Lazarus SVN with FPC 2.2.1 on Windows and 2.2.0 on Linux. The problem occurs in both environments, the version stamps are: v0.9.25 r14253 i386-win32-win32/win64
v0.9.25 r14253M i386-linux-gtk 2 (beta)

Is this a compiler bug or am I missing something?

Thanks,

Paul

Reply by email

ik
to Unknown author

You made the following error:

With FOtherClass Do;

You added semiclone after "do", so you exist the scope of with ...Actually the compiler works really good in this case :)

Ido

Show quoted text 52 lines
I've hit a subtle issue whilst using the With ... Do construct in a program I am working on. I have isolated the behaviour to the following trivial unit: Unit TestClasses; Interface Type TOtherClass = Class Public SomeValue: Boolean; End; TMainClass = Class Public FOtherClass: TOtherClass; Procedure DoSomething; End; Implementation Procedure TMainClass.DoSomething; Var Test: Boolean; Begin // This compiles ok: Test := FOtherClass.SomeValue; // This Fails to compile: With FOtherClass Do; Test := SomeValue; End; End. The compilation halts with: TestClasses.pas(27,22) Error: Identifier not found "SomeValue" I am working off Lazarus SVN with FPC 2.2.1 on Windows and 2.2.0 on Linux. The problem occurs in both environments, the version stamps are: v0.9.25 r14253 i386-win32-win32/win64 v0.9.25 r14253M i386-linux-gtk 2 (beta) Is this a compiler bug or am I missing something? Thanks, Paul _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Unknown author

Many Thanks...

I've been staring at that all morning!
Too many late nights.

Paul

You made the following error:

With FOtherClass Do;

You added semiclone after "do", so you exist the scope of with ...Actually the compiler works really good in this case :)

Ido

Reply by email