Narinder: Very strange behavior and not easy to track down. If you can reproduce it, that’s something that should get into the bug system to get fixed.
Good luck with that. -- Douglas von Roeder 949-910-4084 On Fri, Sep 20, 2019 at 1:18 PM Narinder Chandi via 4D_Tech < 4d_tech@lists.4d.com> wrote: > Douglas, > > Thanks for testing. OK, so I tested in isolation and in fact the code > errors correctly. > > So, I realised that my actual scenario was that the code is called in a > method from On Web Connection. I can set a breakpoint at the offending line > but the debugger aborts at the next line of code after the one that should > trigger a syntax error and code execution ceases. In fact I tried to create > a deliberate syntax error and still see that no syntax error is displayed > and code execution ceases. Not sure if this is a bug or behaviour by > design? Possibly the error is returned to the client making the request but > in my case it's an external service making the request and I can't see the > response the service receives other than the fact it appears to fail. > > Regards, > > Narinder Chandi, > ToolBox Systems Ltd. > > I am available for new consulting opportunities… > http://4d.1045681.n5.nabble.com/ANN-4D-Developer-Available-td5765443.html > -- > > -----Original Message----- > From: Douglas von Roeder <dvonroe...@gmail.com> > Date: Friday, 20 September 2019 at 19:20 > To: 4D Tech Mailing List <4d_tech@lists.4d.com> > Cc: Narinder Chandi <4dtechmailingl...@toolbox.uk.com> > Subject: Re: Silent Failure when Constructing an Object > > Narinder: > I just ran the code you posted on 17R4 (Mac and Windows) and I’m > getting an error message - “Object or a Collection expected” > > After the code completes execution, has 4D created .bar dynamically? > > -- > Douglas von Roeder > 949-910-4084 > > > > > > > > > On Fri, Sep 20, 2019 at 11:02 AM Narinder Chandi via 4D_Tech < > 4d_tech@lists.4d.com> wrote: > > > So, I am writing some code and using C_OBJECT. Using the following > contrived object as an example: > > C_OBJECT($object) > $object:=New object > $object.foo:=New object > $object.foo.foo1:="foo1" > $object.foo.foo2:="foo2" > $object.bar:=New object > $object.bar.bar1:="bar1" > $object.bar.bar2:="bar2" > > The code executes as expected. Sometimes I might accidentally forget > to initialise a nested object - it happens! So, if I replace the above with: > > C_OBJECT($object) > $object:=New object > $object.foo:=New object > $object.foo.foo1:="foo1" > $object.foo.foo2:="foo2" > $object.bar.bar1:="bar1" > $object.bar.bar2:="bar2" > > i.e. I forget "$object.bar:=New object" then the code will silently > fail. Can somebody tell me why the interpreter does not raise an error in > this situation? This was tested with 17.1 and 17.2 on Mac and the behaviour > was the same (i.e. silent code failure) in both versions. > > In the docs for C_OBJECT: > https://doc.4d.com/4Dv17/4D/17.3/C-OBJECT.301-4621707.en.html > it states: > "Important: The C_OBJECT command does not create an object named > variable. If you want to access the properties of the object itself using > object notation, you must first initialize it using the New object command, > otherwise a syntax error is returned (see example)." > > That doesn't seem to be the case - no syntax error is raised and the > code also compiles?! Can somebody point out what I am missing here? Thanks. > > Regards, > > Narinder Chandi, > ToolBox Systems Ltd. > > I am available for new consulting opportunities… > > http://4d.1045681.n5.nabble.com/ANN-4D-Developer-Available-td5765443.html > -- > > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ********************************************************************** > > > > > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:4d_tech-unsubscr...@lists.4d.com > ********************************************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************