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

No runnable code produced / missing unsupported syntax information #274

Open
dragmz opened this issue Dec 8, 2023 · 3 comments
Open

No runnable code produced / missing unsupported syntax information #274

dragmz opened this issue Dec 8, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@dragmz
Copy link

dragmz commented Dec 8, 2023

I've got a project initialized with:

algokit init --template tealscript

boxes.algo.ts:

import { Contract } from '@algorandfoundation/tealscript';

// eslint-disable-next-line no-unused-vars
class TestContract extends Contract {
  items = BoxMap<bytes, bytes>();

  notOkay(): void {
    const item = this.items('test');
    if (!item.exists) {
      item.create(128);
    }
  }

  allOkay(): void {
    if (!this.items('test').exists) {
      this.items('test').create(128);
    }
  }
}
> tealscript boxes.algo.ts

The code produced for notOkay is (all commented out):

// /*
// notOkay(): void {
// const item = this.items('test');
// if (!item.exists) {
// item.create(128);
// }
// }

I'm guessing the syntax isn't supported but there's no information about it in the IDE (VS Code) / the tealscript cmd.

@joe-p
Copy link
Contributor

joe-p commented Dec 8, 2023

Huh interesting. This (saving a reference to a storage property in a variable) definitely isn't supported yet but I would have thought that it would throw an error.

Short term I'll get it to throw an error message, long term I'll work on supporting this because I imagine it's not uncommon to want to do this.

@joe-p joe-p added the bug Something isn't working label Dec 8, 2023
@dragmz
Copy link
Author

dragmz commented Dec 8, 2023

The actual issue here is no feedback from the tealscript boxes.algo.ts call. I thought it has produced the teal file above (with the commented out code) but it didn't and it was just some old code.

The tealscript boxes.algo.ts boxes.teal still provides some error information:

@algorandfoundation\tealscript\node_modules\typescript\lib\typescript.js:29399
        return node.kind === 208 /* SyntaxKind.PropertyAccessExpression */;
                    ^

TypeError: Cannot read properties of undefined (reading 'kind')
TEALScript can not process CallExpression at .\contracts\boxes.algo.ts:7:16
    .\contracts\boxes.algo.ts:8: this.items('test')

@joe-p
Copy link
Contributor

joe-p commented Dec 8, 2023

Ahh ok yeah that makes sense. Yeah definitely need to add a proper error message for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: TODO
Development

No branches or pull requests

2 participants