Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import {
Function,
Element,
ElementKind,
Global,
Field,
Class
Class,
TypedElement
} from "./program";

import {
Expand Down Expand Up @@ -1218,8 +1218,8 @@ export class Flow {
case ExpressionId.GlobalGet: {
// TODO: this is inefficient because it has to read a string
let global = assert(this.parentFunction.program.elementsByName.get(assert(getGlobalGetName(expr))));
assert(global.kind == ElementKind.GLOBAL);
return canConversionOverflow((<Global>global).type, type);
assert(global.kind == ElementKind.GLOBAL || global.kind == ElementKind.ENUMVALUE);
return canConversionOverflow((<TypedElement>global).type, type);
}

case ExpressionId.Binary: {
Expand Down
8 changes: 8 additions & 0 deletions tests/compiler/enum-return-error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"asc_flags": [
],
"stderr": [
"AS200: Conversion from type 'i32' to 'bool' requires an explicit cast.",
"EOF"
]
}
11 changes: 11 additions & 0 deletions tests/compiler/enum-return-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
enum Bar {
Baz
}

function foo(): boolean {
return Bar.Baz;
}

foo();

ERROR("EOF");