Skip to content

fix: Typechecker modification to resolve "using directive" bug#979

Merged
SchoolyB merged 13 commits intoSchoolyB:mainfrom
Scanf-s:fix/using-directive-bug
Jan 10, 2026
Merged

fix: Typechecker modification to resolve "using directive" bug#979
SchoolyB merged 13 commits intoSchoolyB:mainfrom
Scanf-s:fix/using-directive-bug

Conversation

@Scanf-s
Copy link
Copy Markdown
Contributor

@Scanf-s Scanf-s commented Jan 10, 2026

Summary

Resolve #909 - The using directive now correctly brings stdlib module constants into scope, not just functions. Previously, constants like http.OK or os.MAC_OS required the full module prefix even after declaring using http or using os.


Changes

Typecheker

  • Added isStdlibConstant() function that maps module names to their exported constants
  • Updated isKnownIdentifier() to recognize stdlib constants accessible via using directives

Stdlib IsConstant

Added IsConstant=true on below constants

  • http: OK, CREATED, NOT_FOUND, BAD_REQUEST, INTERNAL_SERVER_ERROR, etc
  • os: MAC_OS, LINUX, WINDOWS, CURRENT_OS, line_separator, dev_null
  • math: PI, E, PHI, SQRT2, TAU, INF, NEG_INF, etc
  • time: SUNDAY-SATURDAY, JANUARY-DECEMBER, SECOND, MINUTE, HOUR, DAY, WEEK
  • io: READ_ONLY, WRITE_ONLY, READ_WRITE, APPEND, etc
  • db: ALPHA, ALPHA_DESC, NUMERIC, KEY_LEN, VALUE_LEN, etc
  • uuid: NIL

Some unit tests

Added typechecker tests for constants from all affected modules

  • TestStdlibConstantsWithUsing
  • TestDbConstantsWithUsing
  • TestHttpConstantsWithUsing
  • TestIOConstantsWithUsing
  • TestMathConstantsWithUsing
  • TestOSConstantsWithUsing
  • TestTimeConstantsWithUsing
  • TestUUIDConstantsWithUsin

Test Results

Unit tests

All passed 👍

Integration tests

All passed individually, but please check this issue #978

@Scanf-s Scanf-s changed the title fix: typechecker modification to resolve "using directive" bug fix: Typechecker modification to resolve "using directive" bug Jan 10, 2026
Copy link
Copy Markdown
Owner

@SchoolyB SchoolyB left a comment

Choose a reason for hiding this comment

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

@Scanf-s You cooked with this one 🔥! LGTM 🚀

@SchoolyB SchoolyB merged commit 42cf234 into SchoolyB:main Jan 10, 2026
6 checks passed
SchoolyB pushed a commit that referenced this pull request Apr 3, 2026
* feat(http): add HTTP status code constants

* fix: Add IsConstant checker to all constants in stdlibs

* fix: add stdlib.math constants type checker with unit test codes

* fix: add stdlib.db constants type checker with unit test code

* fix: add stdlib.http constants type checker with unit test code

* chore: rename unit test functions name

* fix: add stdlib.io constants type checker with unit test code

* fix: add stdlib.time, stdlib.uuid constants type checker with unit test code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: using directive does not bring stdlib types, constants, and exports into scope

2 participants