Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AttributeError: 'SymbolSTRSLICE' object has... (*solved*)
#1
For the second time, I get the following output (version 1.2.5):

Quote:marcos$ zxb.py --tap --autorun --BASIC --sinclair colegio_erevest_4.bas
Generating LALR tables
Generating LALR tables
WARNING: Token 'UMINUS' defined, but not used
WARNING: There is 1 unused token
Traceback (most recent call last):
File "/home/marcos/bin/zxb.py", line 255, in <module>
sys.exit(main(sys.argv)) # Exit
File "/home/marcos/bin/zxb.py", line 203, in main
zxbtrad.traverse(zxbtrad.FUNCTIONS) # This will fill MEMORY with pending functions
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 250, in traverse
traverse(l)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 959, in traverse
traverse(i)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 257, in traverse
traverse(i)
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 770, in traverse
traverse(tree.next[1])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 720, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 1004, in traverse
traverse(tree.next[i])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 1008, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 569, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 375, in traverse
traverse(tree.next[0])
File "/opt/zxbasic/1.2.5/zxbtrad.py", line 530, in traverse
if tree.next[0].token != 'STRING' and tree.next[0].token != 'ID' and tree.next[0].symbol._mangled[0] != '_':
AttributeError: 'SymbolSTRSLICE' object has no attribute '_mangled'

I've searched for "mangled" in the forums, but there's no message about it.

It seems it happens when no more syntax errors are found in the source, but I'm not sure. Any clue? Is it a compiler issue or is it caused by my program?
Reply
#2
You should paste the code snippet producing this error, if possible. If you want your code not disclosed for whatever reason, please send it to me in a private message.
Reply
#3
boriel Wrote:You should paste the code snippet producing this error, if possible. If you want your code not disclosed for whatever reason, please send it to me in a private message.

No snippet... the program has more than 1500 lines Smile

I'll try to figure out what's the wrong piece and I will post it.
Reply
#4
More clues:

It happens with 1.2.5 and 1.2.6.

It seems it happens when there are no more syntax errors in the code, but warnings don't make any difference: If I add a final line at the bottom of the source, to force a warning, the error happens anyway; but if the line creates a syntax error, the error doesn't happen. So it seems something is wrong in the next step, after the parsing.

I'll comment out chunks of code, in order to find out any difference.
Reply
#5
I've found out the line that caused the compiling error:

Code:
let ending = genderEnding(val(genderTypes(thing-firstPortableThing+1)))

In fact the same calculation is used in two functions, with the same effect.

The context is:

Code:
dim genderEnding(1 to 3) as string
dim genderTypes as string

let genderTypes="12333131333" ' gender type for every portable thing
let genderEnding(1)="A" ' ending for gender type 1
let genderEnding(2)="AS" ' ending for gender type 2
let genderEnding(3)="" ' ending for gender type 3 (or "O", calculated in the function)

function undefinedArticleEnding(thing as ubyte) as string

    dim ending as string

    let ending = genderEnding(val(genderTypes(thing-firstPortableThing+1)))

    return ending

end function

I isolated the function and the needed DIMs into another file, to debug it. Here you are the results, in chronological order. Every try is marked "!!!ERROR" or "!!!fine and then commented out:

Code:
dim genderEnding(1 to 3) as string
dim genderTypes as string

let genderTypes="12333131333" ' gender type for every portable thing
let genderEnding(1)="A" ' ending for gender type 1
let genderEnding(2)="AS" ' ending for gender type 2
let genderEnding(3)="" ' ending for gender type 3 (or "O", calculated in the function)

function undefinedArticleEnding(thing as ubyte) as string

    dim ending as string

    ' let ending = genderEnding(val(genderTypes(thing-firstPortableThing+1))) ' !!!ERROR

    ' let ending = genderEnding(val(genderTypes(thing-firstPortableThing))) ' !!!ERROR

    ' let ending = "O" ' !!!fine

    ' let ending = genderEnding(val(genderTypes(thing))) ' !!!ERROR

    ' let ending = genderEnding(1) ' !!!fine

    ' let ending = genderEnding(val("1")) ' !!!fine

    ' let ending = genderEnding(val(genderTypes(1))) ' !!!ERROR

    ' let ending = genderEnding(val(genderTypes(0))) ' !!!ERROR

    ' let ending = genderEnding(val("0")) ' !!!fine, a different error: out of range

    ' In parts !!ERROR    
    ' dim gt as ubyte
    ' let gt = val(genderTypes(1))
    ' let ending = genderEnding(gt)
    
    ' In parts !!!fine
    ' dim gt as ubyte
    ' let gt = val("1")
    ' let ending = genderEnding(gt)

    ' In parts !!!fine
    ' dim gt as ubyte
    ' dim gs as string
    ' let gs = "1"
    ' let gt = val(gs)
    ' let ending = genderEnding(gt)

    ' In parts !!!fine
    ' dim gt as ubyte
    ' dim gs as string
    ' let gs = genderTypes(1)
    ' let gt = val(gs)
    ' let ending = genderEnding(gt)

    ' In parts !!!fine
    dim gs as string
    let gs = genderTypes(1)
    let ending = genderEnding(val(gs))

    return ending

end function

I don't understand what's wrong in the code. I suspect it's a compiler issue. I think it has something to do with nesting, don't you think so?
Reply
#6
programandala.net Wrote:I don't understand what's wrong in the code. I suspect it's a compiler issue. I think it has something to do with nesting, don't you think so?
Your code is Ok! :!: It was a compiler bug and has been fixed. Please download 1.2.6r1542b and install.
And please, CHECK the compiler is now working. The problem was in the VAL function:
Code:
REM This code crashes the compiler if version < 1.2.6
LET a$ = "TEST"
PRINT VAL(a$(1))
Download link: <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb/zxbasic-1.2.6r1542b.msi">http://www.boriel.com/files/zxb/zxbasic-1.2.6r1542b.msi</a><!-- m -->
Reply
#7
boriel Wrote:Your code is Ok! :!: It was a compiler bug and has been fixed. Please download 1.2.6r1542b and install.
And please, CHECK the compiler is now working. The problem was in the VAL function:

Now it works fine. Thank you. I have succeeded in compiling my large program by the first time! No warning, no error, no message. It's great. The only inconvenience is the need to put some string functions at the top of the source.

boriel Wrote:Download link: <!-- m --><a class="postlink" href="http://www.boriel.com/files/zxb/zxbasic-1.2.6r1542b.msi">http://www.boriel.com/files/zxb/zxbasic-1.2.6r1542b.msi</a><!-- m -->

It seems the tar.gz is corrupted. I could'nt open it. I used the .zip instead.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)