diff --git a/src/program.ts b/src/program.ts index 11c76101..debd1a50 100644 --- a/src/program.ts +++ b/src/program.ts @@ -66,7 +66,8 @@ import { VariableLikeDeclarationStatement, VariableStatement, - decoratorNameToKind + decoratorNameToKind, + findDecorator } from "./ast"; import { @@ -948,7 +949,7 @@ export class Program extends DiagnosticEmitter { Type.void, // resolved later on declaration, decorators - ? this.checkDecorators(decorators, DecoratorFlags.NONE) + ? this.checkDecorators(decorators, DecoratorFlags.INLINE) : DecoratorFlags.NONE ); staticField.parent = classPrototype; @@ -958,6 +959,13 @@ export class Program extends DiagnosticEmitter { staticField.set(CommonFlags.MODULE_EXPORT); } + if (staticField.hasDecorator(DecoratorFlags.INLINE) && !staticField.is(CommonFlags.READONLY)) { + this.error( + DiagnosticCode.Decorator_0_is_not_valid_here, + assert(findDecorator(DecoratorKind.INLINE, decorators)).range, "inline" + ); + } + // instance fields are remembered until resolved } else { if (isInterface) { @@ -1946,6 +1954,13 @@ export class Program extends DiagnosticEmitter { global.parent = namespace; this.elementsLookup.set(internalName, global); + if (global.hasDecorator(DecoratorFlags.INLINE) && !global.is(CommonFlags.CONST)) { + this.error( + DiagnosticCode.Decorator_0_is_not_valid_here, + assert(findDecorator(DecoratorKind.INLINE, decorators)).range, "inline" + ); + } + if (namespace) { if (namespace.members) { if (namespace.members.has(simpleName)) { diff --git a/std/assembly/allocator/arena.ts b/std/assembly/allocator/arena.ts index 19042e99..087cd217 100644 --- a/std/assembly/allocator/arena.ts +++ b/std/assembly/allocator/arena.ts @@ -14,8 +14,7 @@ var offset: usize = startOffset; // Memory allocator interface -@global -export function __memory_allocate(size: usize): usize { +@global export function __memory_allocate(size: usize): usize { if (size) { if (size > MAX_SIZE_32) unreachable(); let ptr = offset; @@ -36,10 +35,8 @@ export function __memory_allocate(size: usize): usize { return 0; } -@global -export function __memory_free(ptr: usize): void { /* nop */ } +@global export function __memory_free(ptr: usize): void { /* nop */ } -@global -export function __memory_reset(): void { +@global export function __memory_reset(): void { offset = startOffset; }