Skip to content

Feat/ir#82

Open
belicfr wants to merge 103 commits into
devfrom
feat/ir
Open

Feat/ir#82
belicfr wants to merge 103 commits into
devfrom
feat/ir

Conversation

@belicfr
Copy link
Copy Markdown
Member

@belicfr belicfr commented Apr 14, 2026

Changelogs

  • Large name refactoring
  • Deprecate and disable old interpreter
  • Create new analysis process (Type Checking and Type Inference)
  • Create and implement new High Intermediate Representation
  • Create and implement annotation syntax and structure
  • Create and implement modifiers and hooks
  • Create and implement drift-bootstrap module
  • Create drift-ir for potential future QBE backend, in stand by

belicfr added 30 commits January 8, 2026 09:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 140 out of 142 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drift-analysis/src/main/kotlin/drift/analysis/symbols/SymbolCollector.kt Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 140 out of 142 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

drift-core/src/main/kotlin/drift/runtime/ParserType.kt:246

  • ArrayType.asString() currently returns "($type[])", which uses type.toString() (e.g., ObjectType(className=Int, ...)) and adds parentheses, producing unstable/non-language type strings. Use type.asString() and format as ${type.asString()}[] (or whatever the Drift surface syntax is) for consistent user-facing type rendering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drift-analysis/build.gradle.kts Outdated
Comment thread drift-bootstrap/build.gradle.kts Outdated
Comment thread drift-core/src/main/kotlin/drift/parser/classes/ParseClasses.kt
Comment thread drift-analysis/src/main/kotlin/drift/analysis/checkers/TypeChecker.kt Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 140 out of 142 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

drift-core/src/main/kotlin/drift/runtime/ParserType.kt:247

  • ArrayType.asString() uses string interpolation on type directly ("($type[])"). This will call type.toString() (e.g., ObjectType(className=...)) rather than type.asString(), producing incorrect/unstable type names. Build the string from type.asString() instead (and consider dropping the surrounding parentheses unless they’re required by the language grammar).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drift-core/src/main/kotlin/drift/parser/callables/ParseCallables.kt


fun hasClass(name: String) : Boolean =
scopes.last().bindings.containsKey(name)
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SymbolTable.hasClass only checks the current (last) scope. Because SymbolCollector pushes/pops scopes for blocks/functions, this will incorrectly report global classes as missing when type-checking inside nested scopes. Make hasClass search all scopes (similar to lookupNodeId) or delegate to lookupNodeId(name) != null and ensure it only returns true for class symbols.

Suggested change
scopes.last().bindings.containsKey(name)
lookupNodeId(name)?.let { allSymbols[it] is ClassSymbol } ?: false

Copilot uses AI. Check for mistakes.
Comment on lines +122 to +127
is Token.Annotation -> {
val annotation = parseAnnotation()
storedAnnotations.add(annotation)

parseClassStatement()
}
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In parseClassStatement, the Token.Annotation branch recurses immediately after parseAnnotation() without skipping a newline. If the annotation is on its own line (common style), current() will be Token.NewLine and the recursive call will throw DPUnexpectedStatementInClassBodyException. Add skip(Token.NewLine) (or handle Token.NewLine in the dispatcher) before recursing so both @Anno member and @Anno\nmember work.

Copilot uses AI. Check for mistakes.
Comment on lines 173 to 180
if (matchSymbol("{")) {
while (!matchSymbol("}")) {
skip(Token.NewLine)

val c = current()

if (c is Token.Identifier) {
when {
c.isKeyword(Token.Keyword.INIT) -> {
if (hasPrimaryConstructor) {
throw DPOnlyOneConstructorPerClassException()
}

methods.add(parseHook(
forceParameters = true,
disableReturnStatement = true))
}
c.isKeyword(Token.Keyword.IMMUTLET) ||
c.isKeyword(Token.Keyword.MUTLET) -> {

advance(false)

fields += parseLet(
isMutable = c.isKeyword(Token.Keyword.MUTLET),
acceptUnassigned = true)
}
c.isKeyword(Token.Keyword.FUNCTION) -> {
advance()

methods.add(parseFunction())
}
c.isKeyword(Token.Keyword.STATIC) -> {
if (isStaticBlockAlreadyDefined)
throw DPOnlyOneStaticBlockPerClassException()

isStaticBlockAlreadyDefined = true

advance()

expectSymbol("{", advanceOnSuccess = true)

while (!matchSymbol("}")) {
skip(Token.NewLine)

parseClassStaticBlock(staticFields, staticMethods)
}
}
else -> throw DPUnexpectedStatementInClassBodyException()
}
} else {
throw DPUnexpectedStatementInClassBodyException()
}
parseClassStatement()

if (current() is Token.NewLine) advance()
advance()
}
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class-body loop calls advance() unconditionally after parseClassStatement(). Since the parsing routines already advance as they consume tokens, this extra advance can skip over the closing } or the first token of the next member, desynchronizing parsing. Remove this advance() and rely on skip(Token.NewLine) / matchSymbol("}") to drive the loop (similar to parseBlock()).

Copilot uses AI. Check for mistakes.
@belicfr belicfr moved this to In Progress — 2026.0 (LA) in drift May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In Progress — 2026.0 (LA)

Development

Successfully merging this pull request may close these issues.

3 participants