Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dict item not printed #21

Open
lllucius opened this issue Mar 12, 2018 · 2 comments
Open

Dict item not printed #21

lllucius opened this issue Mar 12, 2018 · 2 comments
Labels

Comments

@lllucius
Copy link

When a var is defined as a dict() in a class, printing a value from it can print the variable type followed by an error. Here's some sample code:

class request
    var headers = dict()
    var cookies = dict()

    def sendheaders(s)
        print get(headers, s) + chr(10)
    enddef

    def sendbody(s)
    enddef

    def sendstatus(s)
    enddef

endclass

d = dict()
d("testing") = "123"
print "1: " + d("testing") + chr(10)
print "2: " + get(d, "testing") + chr(10)
print d("testing") + chr(10)

req = new(request)
req.headers("testing") = "123"

h = req.headers

print "3: " + h("testing") + chr(10)
print "4: " + get(h, "testing") + chr(10)
print h("testing") + chr(10)
print "5: " + req.headers("testing") + chr(10)
print "6: " + get(req.headers, "testing") + chr(10)

' This fails with:
'
' DICT
' Error:
'     Ln 34, Col 17
'     Code 30, Abort Code 3
'     Message: Comma or semicolon expected.
print req.headers("testing") + chr(10)

Running this produces:

1: 123
2: 123
123
3: 123
4: 123
123
5: 123
6: 123
DICT
Error:
    Ln 42, Col 17
    Code 30, Abort Code 3
    Message: Comma or semicolon expected.
@paladin-t
Copy link
Owner

Temporarily use print get(req.headers, "testing") + chr(10) instead. I'll refactor the PRINT statement at some point.

@paladin-t paladin-t added the bug label Mar 12, 2018
@lllucius
Copy link
Author

Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants