GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

Autocorrect: No invocations or nesting in string templates #19

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

This can be enforced by syntax and automatically corrected by tooling:

Bad Examples

let username = `test+${Crypto._randomBytes(16)}`;
let username = `test+${Crypto._randomBytes(`${getBase()}`)}`;

Good Examples

let rnd = Crypto._randomBytes(16);
let username = `test+${rnd}`;
let base = getBase();
let rnd = Crypto._randomBytes(16, `base${base}`);
let username = `test+${rnd}`;

Tooling Example

let AUTO_STR_157 = Crypto._randomBytes(16);
let username = `test+${AUTO_STR_157}`;
let AUTO_STR_156 = getBase();
let AUTO_STR_157 = Crypto._randomBytes(16, `base${AUTO_STR_156}`);
let username = `test+${AUTO_STR_157}`;

Dup

Oops. Dupe of #7.