FAQ  •  Register  •  Login

Weird problem with strings / arrays (*solved*)

<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Mon Mar 10, 2014 7:35 pm

Weird problem with strings / arrays (*solved*)

Hopefully my example listing makes it clear!

  Code:
' using version 1.4.0s1864

paper 0
border 0
ink 7
cls

dim textArray(1) as string
dim text as string
dim i as UBYTE

text = "This is a string."

i = 0

textArray(i) = text ' doesn't work - generates "Out of Memory" error if compiled with --debug-memory

textArray(i) = "" + text ' works fine

textArray(0) = text ' works fine

print textArray(0)
pause 0
end

' why does the first method not work?
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sun Apr 20, 2014 7:39 pm

Re: Weird problem with strings / arrays

Just arrived from Barcelona (for easters). :roll:
This is a *NASTY* severe bug :!: I'm going to fix it ASAP, and tell you when it's fixed. Sorry.

UPDATE: Fixed! As always, it turns out to be a single line of code. Please, download and check Version 1.4.0-r1869.
This bug *ALSO EXIST* in previous version ZX Basic 1.3.x :!:
<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Fri Apr 25, 2014 8:10 am

Re: Weird problem with strings / arrays

Thanks for looking at this bug, but unfortunately it still crashes with the "Out of Memory" error (when compiled with --debug-memory).

Also, with this new version, when I compile to TZX, it now generates 3 Python files:

  • parsetab.py (305 KB)
  • zxbasmtab.py (52 KB)
  • zxbpptab.py (22 KB)
The version I was using before (1.4.0s1864) didn't do that!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri Apr 25, 2014 8:38 am

Re: Weird problem with strings / arrays

Mousey wrote:Thanks for looking at this bug, but unfortunately it still crashes with the "Out of Memory" error (when compiled with --debug-memory).

Also, with this new version, when I compile to TZX, it now generates 3 Python files:

  • parsetab.py (305 KB)
  • zxbasmtab.py (52 KB)
  • zxbpptab.py (22 KB)
The version I was using before (1.4.0s1864) didn't do that!

:( Ooops!

It should generate those .py files. The previous version did not, because I already packaged them.
Please, go into the zxb.py directory (BTW you are using the .py version, aren't you?), and execute zxb.py --version ONCE. Leave the generated .py files there, as it will speed up the compiler a lot.

Note: This fix should (at least) correct the Array(i) = TextString. So the assignation is correctly done.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon May 05, 2014 7:29 pm

Re: Weird problem with strings / arrays

[quote="boriel"][quote="Mousey"]Thanks for looking at this bug, but unfortunately it still crashes with the "Out of Memory" error (when compiled with --debug-memory).

Please tell me which version are you using (zxb --version)
To me it all works ok. It should read zxb.py 1.4.0-s1869
<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Tue May 06, 2014 8:14 am

Re: Weird problem with strings / arrays

boriel wrote:Please tell me which version are you using (zxb --version)
To me it all works ok. It should read zxb.py 1.4.0-s1869

I have downloaded and tested with the "Development Version" located here:
http://www.boriel.com/wiki/en/index.php ... IC:Archive

But the zxb.py version contained in both the .zip and the tar.gz packages is stated as "1.3.0-s1771". Was the wrong version uploaded, or has the version string just not been updated?

Either way, the above test program still reports "Out of Memory" when compiled with --debug-memory.

I am running Python version 2.7.6, on Mac OS X 10.9, in case that helps.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Sat Jun 07, 2014 11:02 pm

Re: Weird problem with strings / arrays

Mousey wrote:
boriel wrote:Please tell me which version are you using (zxb --version)
To me it all works ok. It should read zxb.py 1.4.0-s1869

I have downloaded and tested with the "Development Version" located here:
http://www.boriel.com/wiki/en/index.php ... IC:Archive

But the zxb.py version contained in both the .zip and the tar.gz packages is stated as "1.3.0-s1771". Was the wrong version uploaded, or has the version string just not been updated?

Either way, the above test program still reports "Out of Memory" when compiled with --debug-memory.

I am running Python version 2.7.6, on Mac OS X 10.9, in case that helps.

Sorry for the delay (was travelling abroad!).
You were right. It was an upload from an old repo. Please, try now??
<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Wed Jun 18, 2014 2:40 pm

Re: Weird problem with strings / arrays

boriel wrote:You were right. It was an upload from an old repo. Please, try now??

Hi - I have also been travelling (just spent 2 weeks in the USA!), so sorry for the delay replying.

I have downloaded it again, and is now reporting the version as:

zxb.py 1.4.0alpha-s1769

not zxb.py 1.4.0-s1869 as it should be! Was this alpha version uploaded in error?

Also, when I try to compile with this version, it gives an error:
  Code:
Traceback (most recent call last):
  File "../1.4.0/zxb.py", line 348, in <module>
    sys.exit(main(sys.argv))  # Exit
  File "../1.4.0/zxb.py", line 274, in main
    translator.visit(zxbparser.ast)
  File "/Users/MacMini/Dropbox/Boriel/1.4.0/ast_/ast.py", line 102, in visit
    stack.append(last.send(last_result))
  File "/Users/MacMini/Dropbox/Boriel/1.4.0/arch/zx48k/translator.py", line 538, in visit_ARRAYACCESS
    self.emit('param' + self.TSUFFIX(gl.BOUND_TYPE), node.entry.bounds.count)
AttributeError: 'SymbolBOUNDLIST' object has no attribute 'count'

The same code compiles fine with earlier versions.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jun 24, 2014 10:19 pm

Re: Weird problem with strings / arrays

Sorry for the delay.
Apparently I messed up the build script for the python version.
Can you check it now?
Please check the version.
zxb.py --version
should return:
zxb.py 1.4.0-s1876
<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Tue Jul 01, 2014 8:02 am

Re: Weird problem with strings / arrays

boriel wrote:Sorry for the delay.
Apparently I messed up the build script for the python version.
Can you check it now?
Please check the version.
zxb.py --version
should return:
zxb.py 1.4.0-s1876

Well, the good news is that I finally have version 1.4.0-s1876! The bad news is, it still fails to compile the example listing, with the following error:
  Code:
Traceback (most recent call last):
  File "../1.4.0/zxb.py", line 348, in <module>
    sys.exit(main(sys.argv))  # Exit
  File "../1.4.0/zxb.py", line 274, in main
    translator.visit(zxbparser.ast)
  File "/Users/MacMini/Dropbox/Boriel/1.4.0/ast_/ast.py", line 102, in visit
    stack.append(last.send(last_result))
  File "/Users/MacMini/Dropbox/Boriel/1.4.0/arch/zx48k/translator.py", line 542, in visit_ARRAYACCESS
    self.emit('param' + self.TSUFFIX(gl.BOUND_TYPE), node.entry.bounds.count)
AttributeError: 'SymbolBOUNDLIST' object has no attribute 'count'

Very similar to the error given with version 1.4.0alpha-s1769, the only difference I can see is the last error is on line 542 instead of 538.

So, to summarise, here are the versions I have tried and the results:

1.3.0-s1771 - Out of Memory error
1.4.0s1864 - Out of Memory error
1.4.0alpha-s1769 - Fails to compile
1.4.0-s1876 - Fails to compile
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Tue Jul 01, 2014 8:29 am

Re: Weird problem with strings / arrays

Mousey wrote:So, to summarise, here are the versions I have tried and the results:

1.3.0-s1771 - Out of Memory error
1.4.0s1864 - Out of Memory error
1.4.0alpha-s1769 - Fails to compile
1.4.0-s1876 - Fails to compile


Sorry, but can't reproduce your bug. I've used this version.
Please, make a CLEAN installation of the compiler in a new directory and check its version number reads 1.4.0-s1876
I've compiled the listing above successfully (no bugs, no compiler error).
<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Mon Jul 07, 2014 9:19 am

Re: Weird problem with strings / arrays

boriel wrote:Sorry, but can't reproduce your bug. I've used this version.
Please, make a CLEAN installation of the compiler in a new directory and check its version number reads 1.4.0-s1876
I've compiled the listing above successfully (no bugs, no compiler error).

Ok, some good news and bad news. :)

Firstly - I always install a new version to a completely fresh directory, as I know how important this is! But now onto the news:

I now know what is causing the compiler to fail! I forgot to tell you (sorry!) that I compile with both the --debug-memory and also the --debug-array flag (for array boundary checking).

If you try to compile with the --debug-array flag, the above test program fails with the errors I've already posted. However, if you compile with just the --debug-memory flag, it compiles fine, and also the bug is fixed! :)

Thanks for all your work so far, it really is appreciated. Any chance the --debug-array problem could be looked into?
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Mon Jul 07, 2014 9:30 am

Re: Weird problem with strings / arrays

Mousey wrote:If you try to compile with the --debug-array flag, the above test program fails. However, if you compile with just the --debug-memory flag, it compiles file, and also the bug is fixed! :)

Thanks for all your work so far, it really is appreciated. Any chance the --debug-array problem could be looked into?

Oh, thanks a lot!! :!: will check it ASAP!
<<

Mousey

Posts: 10

Joined: Mon Mar 10, 2014 7:27 pm

Post Tue Jul 08, 2014 7:16 am

Re: Weird problem with strings / arrays

boriel wrote:Oh, thanks a lot!! :!: will check it ASAP!

That's great, thanks boriel. :)
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri Jul 18, 2014 11:44 pm

Re: Weird problem with strings / arrays

Mousey wrote:
boriel wrote:Oh, thanks a lot!! :!: will check it ASAP!

That's great, thanks boriel. :)

Try now and download the latest version 1.4.0s1881 and tell me, please. :wink:
Next

Return to Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO