Matthew Winter 4dad4ef64c Give switch range bounds the type of the switch tag
The bounds of a `switch` range case were checked against the tag but
never converted to its type, unlike a single case value, so untyped
bounds took their own default type. Against a `cstring` tag `"0"..="9"`
became `string` bounds, and converting a constant `string` to `cstring`
in the backend crashed the compiler. A `cstring16` or `string16` tag
failed with an invalid conversion from `string` instead. Convert the
bounds to the tag's type, which also gives an invalid bound the same
error as a single case value.

A constant `cstring` or `cstring16` tag forced the `string` comparison
procedures rather than its own, so it failed with a missing
`cstring_le` or `cstring16_le` even with typed bounds.

`lb_get_const_string` expected the data pointer of a constant string to
be a zero index GEP, which LLVM folds to the global itself, and it is
null for an empty string, so it read an invalid constant expression.
Handle both, and have a converted empty string point to its terminator
like a constant `cstring` rather than be nil.

Fixes #7853
2026-10-12 01:31:42 +11:00
…
…
…
…
…
…
…
…
…
…

Odin logo
The Data-Oriented Language for Sane Software Development.


The Odin Programming Language

Odin is a general-purpose programming language with distinct typing, built for high performance, modern systems, and built-in data-oriented data types. The Odin Programming Language, the C alternative for the joy of programming.

Website: https://odin-lang.org/

package main

import "core:fmt"

main :: proc() {
	program := "+ + * 😃 - /"
	accumulator := 0

	for token in program {
		switch token {
		case '+': accumulator += 1
		case '-': accumulator -= 1
		case '*': accumulator *= 2
		case '/': accumulator /= 2
		case '😃': accumulator *= accumulator
		case: // Ignore everything else
		}
	}

	fmt.printf("The program \"%s\" calculates the value %d\n",
	           program, accumulator)
}

Documentation

Getting Started

Instructions for downloading and installing the Odin compiler and libraries.

Nightly Builds

Get the latest nightly builds of Odin.

Learning Odin

Overview of Odin

An overview of the Odin programming language.

Frequently Asked Questions (FAQ)

Answers to common questions about Odin.

Packages

Documentation for all the official packages part of the core and vendor library collections.

Examples

Examples on how to write idiomatic Odin code. Shows how to accomplish specific tasks in Odin, as well as how to use packages from core and vendor.

Odin Documentation

Documentation for the Odin language itself.

Odin Discord

Get live support and talk with other Odin programmers on the Odin Discord.

Articles

The Odin Blog

The official blog of the Odin programming language, featuring announcements, news, and in-depth articles by the Odin team and guests.

Warnings

  • The Odin compiler is still in development.
S
Description
No description provided
Readme Zlib
824 MiB
0 Stars 1 Watchers 0 Forks
Languages
Odin 81.3%
C++ 13.3%
C 4.5%
Python 0.4%
Lua 0.2%
Other 0.2%