A declared function redeclared: one declaration, or a clear error - #386
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Declaring a function a second time failed with an error from the verifier, whether or not the signature was the same:
This is the last item from the #231 review, and it follows the decision to report a clear error rather than support overloads. A declared function binds one external symbol, and a C function has one signature. Picking a signature per call would call one C function with several ABIs.
Change
.d.tsfiles, is left to the first one instead of failing.mlirGen(FunctionDeclaration)records, for each declared function's full name, the declaration it came from and the module it was generated into. The record is per module because:-sharedlibrary's__declstext is parsed again for the next pass, so the same declaration arrives as a new AST node.A first version keyed only by name made the real pass skip those as repeats, which broke 83
-sharedtests before it was pushed.Declarations in different namespaces have different full names and are not compared.
Tests
test-compile-declare-overloads-errorexpects the new message and fails onredefinition of symbol, a stack dump or an assert.00declare_function_twice.ts(compile and jit): the same declaration twice, called.lib.d.tsis full ofdeclares.🤖 Generated with Claude Code