Fix: reject built-in simple type with a trailing dotted name (e.g. number.x.y.z) - #1162
Open
youdie006 wants to merge 1 commit into
Open
Fix: reject built-in simple type with a trailing dotted name (e.g. number.x.y.z)#1162youdie006 wants to merge 1 commit into
youdie006 wants to merge 1 commit into
Conversation
parse_simple_type_or_nominal in teal/ast.tl short-circuits on a built-in simple type (number/string/integer/boolean/thread/any/self) and discards any trailing dotted name parts. As a result an invalid annotation like `local x: number.x.y.z = 1` is accepted as number and type-checks with no errors, while table.x.y.z (not a simple type, nominal path) correctly reports unknown type table.x.y.z. Only take the simple-type short-circuit when there is no dotted continuation (block[NOMINAL_TYPE.NAME + 1] is not an identifier); otherwise fall through to the existing nominal path, which reports the unknown type. Ran make to regenerate the .lua artifacts (teal/ast.lua, tl.lua, teal.lua) from the .tl source per the repo's codegen convention. Fixes teal-language#1136.
hishamhm
reviewed
Aug 19, 2026
| -- Only short-circuit to the built-in simple type when there is no trailing | ||
| -- dotted name part. Otherwise fall through to the nominal path below so that | ||
| -- an invalid annotation like `number.x.y.z` is reported as an unknown type | ||
| -- instead of being silently accepted as `number` (issue #1136). |
Member
There was a problem hiding this comment.
please remove this comment block, it is not necessary
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.
Fixes #1136.
Root cause
parse_simple_type_or_nominalinteal/ast.tlshort-circuits on a built-in simple type (number/string/integer/boolean/thread/any/self) and discards any trailing dotted name parts. As a result an invalid annotation likelocal x: number.x.y.z = 1is accepted asnumberand type-checks with no errors, whiletable.x.y.z(which is not a simple type and takes the nominal path) correctly reportsunknown type table.x.y.z.Fix
Only take the simple-type short-circuit when there is no dotted continuation (
block[NOMINAL_TYPE.NAME + 1]is not anidentifier). Otherwise fall through to the existing nominal path, which reports the unknown type. Ranmaketo regenerate the.luaartifacts (teal/ast.lua,tl.lua,teal.lua) from the.tlsource per the repo's codegen convention.Tests
Added a regression test in
spec/lang/declaration/local_type_spec.luaasserting thatnumber.x.y.z,string.a.b,integer.foo, andboolean.fooeach reportunknown type ...(4 type errors, 0 syntax errors).Verified red/green with busted (test fails before the fix, passes after) and the full suite passes (1928 successes / 0 failures). Plain
number/string/integer/booleanstill type-check;nil.x/any.x/self.x/thread.xstill error cleanly with no crash; a real dotted record type andstring.formatare unaffected.Thanks to @purplesyringa for the clear report.
This change was prepared with AI assistance and reviewed by me before submission.