Conversation
|
|
||
| case ExprKind_TypeUnion: | ||
| case ExprKind_TypeEnum: { | ||
| symbol->state = SymbolState_Resolving; |
There was a problem hiding this comment.
We will need to do additional work to support circular enum references ... for example:
StmtKind :: enum (u8) {
Invalid
Start
// ...
End
ExprStart :: Start + 100
// ...
ExprEnd
DeclStart :: Start + 200
// ...
DeclEnd
}will work fine with a naïve solution should work fine in this case because Start is processed before DeclStart. Do we limit Enums to forbid forward references? Saves us handling the circular checking case
src/llvm.cpp
Outdated
| puts("\n"); | ||
| } | ||
|
|
||
| void printModule(llvm::Module *module) { |
There was a problem hiding this comment.
https://github.com/kai-language/kai-c/pull/49/files#diff-cf87bdfd88530e0c5c46f9b95cf006beR1885
There is already and overload for this called printIR let's just use it for now
| @@ -0,0 +1,4 @@ | |||
|
|
|||
There was a problem hiding this comment.
Damn this came back. I was trying to make it a blank file that git would keep in the repo but ignore changes. The Xcode build system fails if the file isn't there because other xcconfig files #include it and it doesn't run the script to generate this xcconfig file if any of the xcconfig files have any errors. I made my git ignore changes to it but that only works locally for myself. Not sure what would work for any contributors. Any suggestions?
There was a problem hiding this comment.
Also I am running 6.0.1 and planning on trying out 7.0.0rc2 soon so it will change lots if we can't just ignore it.
src/checker.c
Outdated
| if (hasMinMax && currentValue > maxValue) { | ||
| printf("oops!\n"); | ||
| ReportError(pkg, IntOverflowError, item.init->start, | ||
| "Enum case is will overflow backing type"); |
There was a problem hiding this comment.
ReportError(pkg, IntOverflowError, item.init->start,
"Value for enum case exceeds the max value for the enum backing type (%s)",
DescribeType(backingType));
ReportNote(pkg, item.init->start,
"You can force the overflow by explicitly casting the value '%s(%s)"
DescribeType(backingType), DescribeExpr(item.init));| ctx->mode = ExprMode_Type; | ||
| return type; | ||
|
|
||
| unresolved: |
There was a problem hiding this comment.
Fix the prior leak of fields with:
if (fields) ArrayFree(fields);| Type *type = checkExpr(item.init, &itemCtx, pkg); | ||
| if (itemCtx.mode == ExprMode_Unresolved) goto unresolved; // TODO: @Leak this will leak the 'fields' array | ||
|
|
||
| if (!IsConstant(&itemCtx)) { |
There was a problem hiding this comment.
We have a b32 expectType(Package *pkg, Type *type, CheckerContext *ctx, Position pos) do you think we should have a b32 expectConstant(Package *pkg, CheckerContext *ctx, Position pos)? This would mean we would get a more consistent error message. What do you think?
| case SelectorKind_Enum: { | ||
| llvm::Type *type = canonicalize(ctx, info.type); | ||
| if (ctx->returnAddress) { | ||
| UNIMPLEMENTED(); |
There was a problem hiding this comment.
The frontend should report errors if a user tries to address an enum. This should be an ASSERT(false)
No description provided.