mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 07:02:13 +00:00
Emit an error when trying to inline a mutable variable
This commit is contained in:
parent
fafaf423b4
commit
66cc359849
@ -66,7 +66,8 @@ import {
|
|||||||
VariableLikeDeclarationStatement,
|
VariableLikeDeclarationStatement,
|
||||||
VariableStatement,
|
VariableStatement,
|
||||||
|
|
||||||
decoratorNameToKind
|
decoratorNameToKind,
|
||||||
|
findDecorator
|
||||||
} from "./ast";
|
} from "./ast";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -948,7 +949,7 @@ export class Program extends DiagnosticEmitter {
|
|||||||
Type.void, // resolved later on
|
Type.void, // resolved later on
|
||||||
declaration,
|
declaration,
|
||||||
decorators
|
decorators
|
||||||
? this.checkDecorators(decorators, DecoratorFlags.NONE)
|
? this.checkDecorators(decorators, DecoratorFlags.INLINE)
|
||||||
: DecoratorFlags.NONE
|
: DecoratorFlags.NONE
|
||||||
);
|
);
|
||||||
staticField.parent = classPrototype;
|
staticField.parent = classPrototype;
|
||||||
@ -958,6 +959,13 @@ export class Program extends DiagnosticEmitter {
|
|||||||
staticField.set(CommonFlags.MODULE_EXPORT);
|
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
|
// instance fields are remembered until resolved
|
||||||
} else {
|
} else {
|
||||||
if (isInterface) {
|
if (isInterface) {
|
||||||
@ -1946,6 +1954,13 @@ export class Program extends DiagnosticEmitter {
|
|||||||
global.parent = namespace;
|
global.parent = namespace;
|
||||||
this.elementsLookup.set(internalName, global);
|
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) {
|
||||||
if (namespace.members) {
|
if (namespace.members) {
|
||||||
if (namespace.members.has(simpleName)) {
|
if (namespace.members.has(simpleName)) {
|
||||||
|
@ -14,8 +14,7 @@ var offset: usize = startOffset;
|
|||||||
|
|
||||||
// Memory allocator interface
|
// Memory allocator interface
|
||||||
|
|
||||||
@global
|
@global export function __memory_allocate(size: usize): usize {
|
||||||
export function __memory_allocate(size: usize): usize {
|
|
||||||
if (size) {
|
if (size) {
|
||||||
if (size > MAX_SIZE_32) unreachable();
|
if (size > MAX_SIZE_32) unreachable();
|
||||||
let ptr = offset;
|
let ptr = offset;
|
||||||
@ -36,10 +35,8 @@ export function __memory_allocate(size: usize): usize {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@global
|
@global export function __memory_free(ptr: usize): void { /* nop */ }
|
||||||
export function __memory_free(ptr: usize): void { /* nop */ }
|
|
||||||
|
|
||||||
@global
|
@global export function __memory_reset(): void {
|
||||||
export function __memory_reset(): void {
|
|
||||||
offset = startOffset;
|
offset = startOffset;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user