Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Quark allows you to reference an undefined list; generated code throws errors in all languages #40

Open
janicedatawire opened this issue Oct 26, 2015 · 0 comments

Comments

@janicedatawire
Copy link
Contributor

Quark compiles code that adds elements to a list that has not been initialized but the generated code throws errors in all languages.

Quark code:

package likes{

    class Color {
        List<String> favorites;
    } 
}

void main() {
    int i=0;
    likes.Color myColors=new likes.Color();
    myColors.favorites.add("red");
    myColors.favorites.add("green");
    myColors.favorites.add("blue");
    myColors.favorites.add("purple");
    ...
}

Error in Javascript:

/Users/janicekarin/quark-examples/javascript/list.js:9
    ((myColors).favorites).push("red");
                          ^
TypeError: Cannot read property 'push' of null
    at main (/Users/janicekarin/quark-examples/javascript/list.js:9:27)
    at Object.<anonymous> (/Users/janicekarin/quark-examples/javascript/list.js:25:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

Error in Python:

  File "list.py", line 26, in <module>
    main()
  File "list.py", line 10, in main
    ((myColors).favorites).append("red");
AttributeError: 'NoneType' object has no attribute 'append'

in Java:

Exception in thread "main" java.lang.NullPointerException
    at Functions.main(Functions.java:5)
    at Functions.main(Functions.java:20)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant