authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-08 18:09:08-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-08 18:09:08-04:00
loge0f0e2aace9e819545388c46547188ee6296178b
tree674a78c834c9d440e8f07da8a24bff76f35ecc71
parentf74c29b49a550e5e7029fde46de93068a9eecb46
signaturelock-open Commit is signed but in an unrecognized format.

generated docs: error sets in fn docs


7 files changed, 172 insertions(+), 132 deletions(-)

lib/std/os.zig+41-109
...@@ -183,7 +183,7 @@ pub fn abort() noreturn {...@@ -183,7 +183,7 @@ pub fn abort() noreturn {
183 exit(127);183 exit(127);
184}184}
185185
186pub const RaiseError = error{Unexpected};186pub const RaiseError = UnexpectedError;
187187
188pub fn raise(sig: u8) RaiseError!void {188pub fn raise(sig: u8) RaiseError!void {
189 if (builtin.link_libc) {189 if (builtin.link_libc) {
...@@ -215,10 +215,7 @@ pub fn raise(sig: u8) RaiseError!void {...@@ -215,10 +215,7 @@ pub fn raise(sig: u8) RaiseError!void {
215 @compileError("std.os.raise unimplemented for this target");215 @compileError("std.os.raise unimplemented for this target");
216}216}
217217
218pub const KillError = error{218pub const KillError = error{PermissionDenied} || UnexpectedError;
219 PermissionDenied,
220 Unexpected,
221};
222219
223pub fn kill(pid: pid_t, sig: u8) KillError!void {220pub fn kill(pid: pid_t, sig: u8) KillError!void {
224 switch (errno(system.kill(pid, sig))) {221 switch (errno(system.kill(pid, sig))) {
...@@ -266,9 +263,7 @@ pub const ReadError = error{...@@ -266,9 +263,7 @@ pub const ReadError = error{
266 /// This error occurs when no global event loop is configured,263 /// This error occurs when no global event loop is configured,
267 /// and reading from the file descriptor would block.264 /// and reading from the file descriptor would block.
268 WouldBlock,265 WouldBlock,
269266} || UnexpectedError;
270 Unexpected,
271};
272267
273/// Returns the number of bytes that were read, which can be less than268/// Returns the number of bytes that were read, which can be less than
274/// buf.len. If 0 bytes were read, that means EOF.269/// buf.len. If 0 bytes were read, that means EOF.
...@@ -385,8 +380,7 @@ pub const WriteError = error{...@@ -385,8 +380,7 @@ pub const WriteError = error{
385 BrokenPipe,380 BrokenPipe,
386 SystemResources,381 SystemResources,
387 OperationAborted,382 OperationAborted,
388 Unexpected,383} || UnexpectedError;
389};
390384
391/// Write to a file descriptor. Keeps trying if it gets interrupted.385/// Write to a file descriptor. Keeps trying if it gets interrupted.
392/// This function is for blocking file descriptors only.386/// This function is for blocking file descriptors only.
...@@ -548,8 +542,7 @@ pub const OpenError = error{...@@ -548,8 +542,7 @@ pub const OpenError = error{
548 NotDir,542 NotDir,
549 PathAlreadyExists,543 PathAlreadyExists,
550 DeviceBusy,544 DeviceBusy,
551 Unexpected,545} || UnexpectedError;
552};
553546
554/// Open and possibly create a file. Keeps trying if it gets interrupted.547/// Open and possibly create a file. Keeps trying if it gets interrupted.
555/// See also `openC`.548/// See also `openC`.
...@@ -748,9 +741,7 @@ pub const ExecveError = error{...@@ -748,9 +741,7 @@ pub const ExecveError = error{
748 ProcessFdQuotaExceeded,741 ProcessFdQuotaExceeded,
749 SystemFdQuotaExceeded,742 SystemFdQuotaExceeded,
750 NameTooLong,743 NameTooLong,
751744} || UnexpectedError;
752 Unexpected,
753};
754745
755fn execveErrnoToErr(err: usize) ExecveError {746fn execveErrnoToErr(err: usize) ExecveError {
756 assert(err > 0);747 assert(err > 0);
...@@ -808,8 +799,7 @@ pub fn getenvC(key: [*]const u8) ?[]const u8 {...@@ -808,8 +799,7 @@ pub fn getenvC(key: [*]const u8) ?[]const u8 {
808pub const GetCwdError = error{799pub const GetCwdError = error{
809 NameTooLong,800 NameTooLong,
810 CurrentWorkingDirectoryUnlinked,801 CurrentWorkingDirectoryUnlinked,
811 Unexpected,802} || UnexpectedError;
812};
813803
814/// The result is a slice of out_buffer, indexed from 0.804/// The result is a slice of out_buffer, indexed from 0.
815pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 {805pub fn getcwd(out_buffer: []u8) GetCwdError![]u8 {
...@@ -846,8 +836,7 @@ pub const SymLinkError = error{...@@ -846,8 +836,7 @@ pub const SymLinkError = error{
846 NameTooLong,836 NameTooLong,
847 InvalidUtf8,837 InvalidUtf8,
848 BadPathName,838 BadPathName,
849 Unexpected,839} || UnexpectedError;
850};
851840
852/// Creates a symbolic link named `sym_link_path` which contains the string `target_path`.841/// Creates a symbolic link named `sym_link_path` which contains the string `target_path`.
853/// A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent842/// A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent
...@@ -932,7 +921,6 @@ pub const UnlinkError = error{...@@ -932,7 +921,6 @@ pub const UnlinkError = error{
932 NotDir,921 NotDir,
933 SystemResources,922 SystemResources,
934 ReadOnlyFileSystem,923 ReadOnlyFileSystem,
935 Unexpected,
936924
937 /// On Windows, file paths must be valid Unicode.925 /// On Windows, file paths must be valid Unicode.
938 InvalidUtf8,926 InvalidUtf8,
...@@ -940,7 +928,7 @@ pub const UnlinkError = error{...@@ -940,7 +928,7 @@ pub const UnlinkError = error{
940 /// On Windows, file paths cannot contain these characters:928 /// On Windows, file paths cannot contain these characters:
941 /// '/', '*', '?', '"', '<', '>', '|'929 /// '/', '*', '?', '"', '<', '>', '|'
942 BadPathName,930 BadPathName,
943};931} || UnexpectedError;
944932
945/// Delete a name and possibly the file it refers to.933/// Delete a name and possibly the file it refers to.
946/// See also `unlinkC`.934/// See also `unlinkC`.
...@@ -996,8 +984,7 @@ const RenameError = error{...@@ -996,8 +984,7 @@ const RenameError = error{
996 RenameAcrossMountPoints,984 RenameAcrossMountPoints,
997 InvalidUtf8,985 InvalidUtf8,
998 BadPathName,986 BadPathName,
999 Unexpected,987} || UnexpectedError;
1000};
1001988
1002/// Change the name or location of a file.989/// Change the name or location of a file.
1003pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void {990pub fn rename(old_path: []const u8, new_path: []const u8) RenameError!void {
...@@ -1064,8 +1051,7 @@ pub const MakeDirError = error{...@@ -1064,8 +1051,7 @@ pub const MakeDirError = error{
1064 ReadOnlyFileSystem,1051 ReadOnlyFileSystem,
1065 InvalidUtf8,1052 InvalidUtf8,
1066 BadPathName,1053 BadPathName,
1067 Unexpected,1054} || UnexpectedError;
1068};
10691055
1070/// Create a directory.1056/// Create a directory.
1071/// `mode` is ignored on Windows.1057/// `mode` is ignored on Windows.
...@@ -1116,8 +1102,7 @@ pub const DeleteDirError = error{...@@ -1116,8 +1102,7 @@ pub const DeleteDirError = error{
1116 ReadOnlyFileSystem,1102 ReadOnlyFileSystem,
1117 InvalidUtf8,1103 InvalidUtf8,
1118 BadPathName,1104 BadPathName,
1119 Unexpected,1105} || UnexpectedError;
1120};
11211106
1122/// Deletes an empty directory.1107/// Deletes an empty directory.
1123pub fn rmdir(dir_path: []const u8) DeleteDirError!void {1108pub fn rmdir(dir_path: []const u8) DeleteDirError!void {
...@@ -1163,8 +1148,7 @@ pub const ChangeCurDirError = error{...@@ -1163,8 +1148,7 @@ pub const ChangeCurDirError = error{
1163 FileNotFound,1148 FileNotFound,
1164 SystemResources,1149 SystemResources,
1165 NotDir,1150 NotDir,
1166 Unexpected,1151} || UnexpectedError;
1167};
11681152
1169/// Changes the current working directory of the calling process.1153/// Changes the current working directory of the calling process.
1170/// `dir_path` is recommended to be a UTF-8 encoded string.1154/// `dir_path` is recommended to be a UTF-8 encoded string.
...@@ -1206,8 +1190,7 @@ pub const ReadLinkError = error{...@@ -1206,8 +1190,7 @@ pub const ReadLinkError = error{
1206 FileNotFound,1190 FileNotFound,
1207 SystemResources,1191 SystemResources,
1208 NotDir,1192 NotDir,
1209 Unexpected,1193} || UnexpectedError;
1210};
12111194
1212/// Read value of a symbolic link.1195/// Read value of a symbolic link.
1213/// The return value is a slice of `out_buffer` from index 0.1196/// The return value is a slice of `out_buffer` from index 0.
...@@ -1247,8 +1230,7 @@ pub const SetIdError = error{...@@ -1247,8 +1230,7 @@ pub const SetIdError = error{
1247 ResourceLimitReached,1230 ResourceLimitReached,
1248 InvalidUserId,1231 InvalidUserId,
1249 PermissionDenied,1232 PermissionDenied,
1250 Unexpected,1233} || UnexpectedError;
1251};
12521234
1253pub fn setuid(uid: u32) SetIdError!void {1235pub fn setuid(uid: u32) SetIdError!void {
1254 switch (errno(system.setuid(uid))) {1236 switch (errno(system.setuid(uid))) {
...@@ -1357,9 +1339,7 @@ pub const SocketError = error{...@@ -1357,9 +1339,7 @@ pub const SocketError = error{
13571339
1358 /// The protocol type or the specified protocol is not supported within this domain.1340 /// The protocol type or the specified protocol is not supported within this domain.
1359 ProtocolNotSupported,1341 ProtocolNotSupported,
13601342} || UnexpectedError;
1361 Unexpected,
1362};
13631343
1364pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!i32 {1344pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!i32 {
1365 const rc = system.socket(domain, socket_type, protocol);1345 const rc = system.socket(domain, socket_type, protocol);
...@@ -1409,9 +1389,7 @@ pub const BindError = error{...@@ -1409,9 +1389,7 @@ pub const BindError = error{
14091389
1410 /// The socket inode would reside on a read-only filesystem.1390 /// The socket inode would reside on a read-only filesystem.
1411 ReadOnlyFileSystem,1391 ReadOnlyFileSystem,
14121392} || UnexpectedError;
1413 Unexpected,
1414};
14151393
1416/// addr is `*const T` where T is one of the sockaddr1394/// addr is `*const T` where T is one of the sockaddr
1417pub fn bind(fd: i32, addr: *const sockaddr) BindError!void {1395pub fn bind(fd: i32, addr: *const sockaddr) BindError!void {
...@@ -1448,9 +1426,7 @@ const ListenError = error{...@@ -1448,9 +1426,7 @@ const ListenError = error{
14481426
1449 /// The socket is not of a type that supports the listen() operation.1427 /// The socket is not of a type that supports the listen() operation.
1450 OperationNotSupported,1428 OperationNotSupported,
14511429} || UnexpectedError;
1452 Unexpected,
1453};
14541430
1455pub fn listen(sockfd: i32, backlog: u32) ListenError!void {1431pub fn listen(sockfd: i32, backlog: u32) ListenError!void {
1456 const rc = system.listen(sockfd, backlog);1432 const rc = system.listen(sockfd, backlog);
...@@ -1487,9 +1463,7 @@ pub const AcceptError = error{...@@ -1487,9 +1463,7 @@ pub const AcceptError = error{
14871463
1488 /// Firewall rules forbid connection.1464 /// Firewall rules forbid connection.
1489 BlockedByFirewall,1465 BlockedByFirewall,
14901466} || UnexpectedError;
1491 Unexpected,
1492};
14931467
1494/// Accept a connection on a socket. `fd` must be opened in blocking mode.1468/// Accept a connection on a socket. `fd` must be opened in blocking mode.
1495/// See also `accept4_async`.1469/// See also `accept4_async`.
...@@ -1559,9 +1533,7 @@ pub const EpollCreateError = error{...@@ -1559,9 +1533,7 @@ pub const EpollCreateError = error{
15591533
1560 /// There was insufficient memory to create the kernel object.1534 /// There was insufficient memory to create the kernel object.
1561 SystemResources,1535 SystemResources,
15621536} || UnexpectedError;
1563 Unexpected,
1564};
15651537
1566pub fn epoll_create1(flags: u32) EpollCreateError!i32 {1538pub fn epoll_create1(flags: u32) EpollCreateError!i32 {
1567 const rc = system.epoll_create1(flags);1539 const rc = system.epoll_create1(flags);
...@@ -1600,9 +1572,7 @@ pub const EpollCtlError = error{...@@ -1600,9 +1572,7 @@ pub const EpollCtlError = error{
1600 /// The target file fd does not support epoll. This error can occur if fd refers to,1572 /// The target file fd does not support epoll. This error can occur if fd refers to,
1601 /// for example, a regular file or a directory.1573 /// for example, a regular file or a directory.
1602 FileDescriptorIncompatibleWithEpoll,1574 FileDescriptorIncompatibleWithEpoll,
16031575} || UnexpectedError;
1604 Unexpected,
1605};
16061576
1607pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void {1577pub fn epoll_ctl(epfd: i32, op: u32, fd: i32, event: ?*epoll_event) EpollCtlError!void {
1608 const rc = system.epoll_ctl(epfd, op, fd, event);1578 const rc = system.epoll_ctl(epfd, op, fd, event);
...@@ -1643,8 +1613,7 @@ pub const EventFdError = error{...@@ -1643,8 +1613,7 @@ pub const EventFdError = error{
1643 SystemResources,1613 SystemResources,
1644 ProcessFdQuotaExceeded,1614 ProcessFdQuotaExceeded,
1645 SystemFdQuotaExceeded,1615 SystemFdQuotaExceeded,
1646 Unexpected,1616} || UnexpectedError;
1647};
16481617
1649pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 {1618pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 {
1650 const rc = system.eventfd(initval, flags);1619 const rc = system.eventfd(initval, flags);
...@@ -1663,9 +1632,7 @@ pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 {...@@ -1663,9 +1632,7 @@ pub fn eventfd(initval: u32, flags: u32) EventFdError!i32 {
1663pub const GetSockNameError = error{1632pub const GetSockNameError = error{
1664 /// Insufficient resources were available in the system to perform the operation.1633 /// Insufficient resources were available in the system to perform the operation.
1665 SystemResources,1634 SystemResources,
16661635} || UnexpectedError;
1667 Unexpected,
1668};
16691636
1670pub fn getsockname(sockfd: i32) GetSockNameError!sockaddr {1637pub fn getsockname(sockfd: i32) GetSockNameError!sockaddr {
1671 var addr: sockaddr = undefined;1638 var addr: sockaddr = undefined;
...@@ -1714,9 +1681,7 @@ pub const ConnectError = error{...@@ -1714,9 +1681,7 @@ pub const ConnectError = error{
1714 /// Timeout while attempting connection. The server may be too busy to accept new connections. Note1681 /// Timeout while attempting connection. The server may be too busy to accept new connections. Note
1715 /// that for IP sockets the timeout may be very long when syncookies are enabled on the server.1682 /// that for IP sockets the timeout may be very long when syncookies are enabled on the server.
1716 ConnectionTimedOut,1683 ConnectionTimedOut,
17171684} || UnexpectedError;
1718 Unexpected,
1719};
17201685
1721/// Initiate a connection on a socket.1686/// Initiate a connection on a socket.
1722/// This is for blocking file descriptors only.1687/// This is for blocking file descriptors only.
...@@ -1824,10 +1789,7 @@ pub fn waitpid(pid: i32, flags: u32) u32 {...@@ -1824,10 +1789,7 @@ pub fn waitpid(pid: i32, flags: u32) u32 {
1824 }1789 }
1825}1790}
18261791
1827pub const FStatError = error{1792pub const FStatError = error{SystemResources} || UnexpectedError;
1828 SystemResources,
1829 Unexpected,
1830};
18311793
1832pub fn fstat(fd: fd_t) FStatError!Stat {1794pub fn fstat(fd: fd_t) FStatError!Stat {
1833 var stat: Stat = undefined;1795 var stat: Stat = undefined;
...@@ -1856,9 +1818,7 @@ pub const KQueueError = error{...@@ -1856,9 +1818,7 @@ pub const KQueueError = error{
18561818
1857 /// The system-wide limit on the total number of open files has been reached.1819 /// The system-wide limit on the total number of open files has been reached.
1858 SystemFdQuotaExceeded,1820 SystemFdQuotaExceeded,
18591821} || UnexpectedError;
1860 Unexpected,
1861};
18621822
1863pub fn kqueue() KQueueError!i32 {1823pub fn kqueue() KQueueError!i32 {
1864 const rc = system.kqueue();1824 const rc = system.kqueue();
...@@ -1922,8 +1882,7 @@ pub const INotifyInitError = error{...@@ -1922,8 +1882,7 @@ pub const INotifyInitError = error{
1922 ProcessFdQuotaExceeded,1882 ProcessFdQuotaExceeded,
1923 SystemFdQuotaExceeded,1883 SystemFdQuotaExceeded,
1924 SystemResources,1884 SystemResources,
1925 Unexpected,1885} || UnexpectedError;
1926};
19271886
1928/// initialize an inotify instance1887/// initialize an inotify instance
1929pub fn inotify_init1(flags: u32) INotifyInitError!i32 {1888pub fn inotify_init1(flags: u32) INotifyInitError!i32 {
...@@ -1944,8 +1903,7 @@ pub const INotifyAddWatchError = error{...@@ -1944,8 +1903,7 @@ pub const INotifyAddWatchError = error{
1944 FileNotFound,1903 FileNotFound,
1945 SystemResources,1904 SystemResources,
1946 UserResourceLimitReached,1905 UserResourceLimitReached,
1947 Unexpected,1906} || UnexpectedError;
1948};
19491907
1950/// add a watch to an initialized inotify instance1908/// add a watch to an initialized inotify instance
1951pub fn inotify_add_watch(inotify_fd: i32, pathname: []const u8, mask: u32) INotifyAddWatchError!i32 {1909pub fn inotify_add_watch(inotify_fd: i32, pathname: []const u8, mask: u32) INotifyAddWatchError!i32 {
...@@ -1992,8 +1950,7 @@ pub const MProtectError = error{...@@ -1992,8 +1950,7 @@ pub const MProtectError = error{
1992 /// dle of a region currently protected as PROT_READ|PROT_WRITE would result in three map‐1950 /// dle of a region currently protected as PROT_READ|PROT_WRITE would result in three map‐
1993 /// pings: two read/write mappings at each end and a read-only mapping in the middle.)1951 /// pings: two read/write mappings at each end and a read-only mapping in the middle.)
1994 OutOfMemory,1952 OutOfMemory,
1995 Unexpected,1953} || UnexpectedError;
1996};
19971954
1998/// `memory.len` must be page-aligned.1955/// `memory.len` must be page-aligned.
1999pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectError!void {1956pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectError!void {
...@@ -2007,10 +1964,7 @@ pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectErro...@@ -2007,10 +1964,7 @@ pub fn mprotect(memory: []align(mem.page_size) u8, protection: u32) MProtectErro
2007 }1964 }
2008}1965}
20091966
2010pub const ForkError = error{1967pub const ForkError = error{SystemResources} || UnexpectedError;
2011 SystemResources,
2012 Unexpected,
2013};
20141968
2015pub fn fork() ForkError!pid_t {1969pub fn fork() ForkError!pid_t {
2016 const rc = system.fork();1970 const rc = system.fork();
...@@ -2037,8 +1991,7 @@ pub const MMapError = error{...@@ -2037,8 +1991,7 @@ pub const MMapError = error{
2037 PermissionDenied,1991 PermissionDenied,
2038 LockedMemoryLimitExceeded,1992 LockedMemoryLimitExceeded,
2039 OutOfMemory,1993 OutOfMemory,
2040 Unexpected,1994} || UnexpectedError;
2041};
20421995
2043/// Map files or devices into memory.1996/// Map files or devices into memory.
2044/// Use of a mapped region can result in these signals:1997/// Use of a mapped region can result in these signals:
...@@ -2101,9 +2054,7 @@ pub const AccessError = error{...@@ -2101,9 +2054,7 @@ pub const AccessError = error{
21012054
2102 /// On Windows, file paths must be valid Unicode.2055 /// On Windows, file paths must be valid Unicode.
2103 InvalidUtf8,2056 InvalidUtf8,
21042057} || UnexpectedError;
2105 Unexpected,
2106};
21072058
2108/// check user's permissions for a file2059/// check user's permissions for a file
2109/// TODO currently this assumes `mode` is `F_OK` on Windows.2060/// TODO currently this assumes `mode` is `F_OK` on Windows.
...@@ -2161,8 +2112,7 @@ pub fn accessW(path: [*]const u16, mode: u32) windows.GetFileAttributesError!voi...@@ -2161,8 +2112,7 @@ pub fn accessW(path: [*]const u16, mode: u32) windows.GetFileAttributesError!voi
2161pub const PipeError = error{2112pub const PipeError = error{
2162 SystemFdQuotaExceeded,2113 SystemFdQuotaExceeded,
2163 ProcessFdQuotaExceeded,2114 ProcessFdQuotaExceeded,
2164 Unexpected,2115} || UnexpectedError;
2165};
21662116
2167/// Creates a unidirectional data channel that can be used for interprocess communication.2117/// Creates a unidirectional data channel that can be used for interprocess communication.
2168pub fn pipe() PipeError![2]fd_t {2118pub fn pipe() PipeError![2]fd_t {
...@@ -2193,8 +2143,7 @@ pub const SysCtlError = error{...@@ -2193,8 +2143,7 @@ pub const SysCtlError = error{
2193 PermissionDenied,2143 PermissionDenied,
2194 SystemResources,2144 SystemResources,
2195 NameTooLong,2145 NameTooLong,
2196 Unexpected,2146} || UnexpectedError;
2197};
21982147
2199pub fn sysctl(2148pub fn sysctl(
2200 name: []const c_int,2149 name: []const c_int,
...@@ -2237,10 +2186,7 @@ pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void {...@@ -2237,10 +2186,7 @@ pub fn gettimeofday(tv: ?*timeval, tz: ?*timezone) void {
2237 }2186 }
2238}2187}
22392188
2240pub const SeekError = error{2189pub const SeekError = error{Unseekable} || UnexpectedError;
2241 Unseekable,
2242 Unexpected,
2243};
22442190
2245/// Repositions read/write file offset relative to the beginning.2191/// Repositions read/write file offset relative to the beginning.
2246pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {2192pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void {
...@@ -2382,9 +2328,7 @@ pub const RealPathError = error{...@@ -2382,9 +2328,7 @@ pub const RealPathError = error{
2382 InvalidUtf8,2328 InvalidUtf8,
23832329
2384 PathAlreadyExists,2330 PathAlreadyExists,
23852331} || UnexpectedError;
2386 Unexpected,
2387};
23882332
2389/// Return the canonicalized absolute pathname.2333/// Return the canonicalized absolute pathname.
2390/// Expands all symbolic links and resolves references to `.`, `..`, and2334/// Expands all symbolic links and resolves references to `.`, `..`, and
...@@ -2548,10 +2492,7 @@ pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_inf...@@ -2548,10 +2492,7 @@ pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_inf
2548 return last_r;2492 return last_r;
2549}2493}
25502494
2551pub const ClockGetTimeError = error{2495pub const ClockGetTimeError = error{UnsupportedClock} || UnexpectedError;
2552 UnsupportedClock,
2553 Unexpected,
2554};
25552496
2556pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {2497pub fn clock_gettime(clk_id: i32, tp: *timespec) ClockGetTimeError!void {
2557 switch (errno(system.clock_gettime(clk_id, tp))) {2498 switch (errno(system.clock_gettime(clk_id, tp))) {
...@@ -2571,10 +2512,7 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void {...@@ -2571,10 +2512,7 @@ pub fn clock_getres(clk_id: i32, res: *timespec) ClockGetTimeError!void {
2571 }2512 }
2572}2513}
25732514
2574pub const SchedGetAffinityError = error{2515pub const SchedGetAffinityError = error{PermissionDenied} || UnexpectedError;
2575 PermissionDenied,
2576 Unexpected,
2577};
25782516
2579pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {2517pub fn sched_getaffinity(pid: pid_t) SchedGetAffinityError!cpu_set_t {
2580 var set: cpu_set_t = undefined;2518 var set: cpu_set_t = undefined;
...@@ -2628,8 +2566,7 @@ pub const SigaltstackError = error{...@@ -2628,8 +2566,7 @@ pub const SigaltstackError = error{
26282566
2629 /// Attempted to change the signal stack while it was active.2567 /// Attempted to change the signal stack while it was active.
2630 PermissionDenied,2568 PermissionDenied,
2631 Unexpected,2569} || UnexpectedError;
2632};
26332570
2634pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void {2571pub fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) SigaltstackError!void {
2635 if (windows.is_the_target or uefi.is_the_target or wasi.is_the_target)2572 if (windows.is_the_target or uefi.is_the_target or wasi.is_the_target)
...@@ -2677,9 +2614,7 @@ pub const FutimensError = error{...@@ -2677,9 +2614,7 @@ pub const FutimensError = error{
2677 PermissionDenied,2614 PermissionDenied,
26782615
2679 ReadOnlyFileSystem,2616 ReadOnlyFileSystem,
26802617} || UnexpectedError;
2681 Unexpected,
2682};
26832618
2684pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void {2619pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void {
2685 switch (errno(system.futimens(fd, times))) {2620 switch (errno(system.futimens(fd, times))) {
...@@ -2694,10 +2629,7 @@ pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void {...@@ -2694,10 +2629,7 @@ pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void {
2694 }2629 }
2695}2630}
26962631
2697pub const GetHostNameError = error{2632pub const GetHostNameError = error{PermissionDenied} || UnexpectedError;
2698 PermissionDenied,
2699 Unexpected,
2700};
27012633
2702pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 {2634pub fn gethostname(name_buffer: *[HOST_NAME_MAX]u8) GetHostNameError![]u8 {
2703 if (builtin.link_libc) {2635 if (builtin.link_libc) {
lib/std/special/docs/index.html+15-2
...@@ -87,7 +87,7 @@...@@ -87,7 +87,7 @@
87 #listPkgs li a {87 #listPkgs li a {
88 display: block;88 display: block;
89 color: #000;89 color: #000;
90 padding: 8px 16px;90 padding: 0.5em 1em;
91 text-decoration: none;91 text-decoration: none;
92 }92 }
93 #listPkgs li a:hover {93 #listPkgs li a:hover {
...@@ -145,6 +145,13 @@...@@ -145,6 +145,13 @@
145 #listSearchResults li.selected {145 #listSearchResults li.selected {
146 background-color: #93e196;146 background-color: #93e196;
147 }147 }
148
149 #tableFnErrors tr td:first-child{
150 text-align: right;
151 font-weight: bold;
152 vertical-align: top;
153 }
154
148 .tok-kw {155 .tok-kw {
149 color: #333;156 color: #333;
150 font-weight: bold;157 font-weight: bold;
...@@ -262,7 +269,13 @@...@@ -262,7 +269,13 @@
262 </div>269 </div>
263 <h1 id="hdrName" class="hidden"></h1>270 <h1 id="hdrName" class="hidden"></h1>
264 <div id="fnDocs" class="hidden"></div>271 <div id="fnDocs" class="hidden"></div>
265 <div id="fnErrors" class="hidden"></div>272 <div id="sectFnErrors" class="hidden">
273 <h2>Errors</h2>
274 <div id="fnErrorsAnyError">
275 <p><span class="tok-type">anyerror</span> means the error set is known only at runtime.</p>
276 </div>
277 <table id="tableFnErrors"><tbody id="listFnErrors"></tbody></table>
278 </div>
266 <div id="fnExamples" class="hidden"></div>279 <div id="fnExamples" class="hidden"></div>
267 <div id="fnNoExamples" class="hidden">280 <div id="fnNoExamples" class="hidden">
268 <p>This function is not tested or referenced.</p>281 <p>This function is not tested or referenced.</p>
lib/std/special/docs/main.js+70-4
...@@ -13,7 +13,10 @@...@@ -13,7 +13,10 @@
13 var domFnProto = document.getElementById("fnProto");13 var domFnProto = document.getElementById("fnProto");
14 var domFnProtoCode = document.getElementById("fnProtoCode");14 var domFnProtoCode = document.getElementById("fnProtoCode");
15 var domFnDocs = document.getElementById("fnDocs");15 var domFnDocs = document.getElementById("fnDocs");
16 var domFnErrors = document.getElementById("fnErrors");16 var domSectFnErrors = document.getElementById("sectFnErrors");
17 var domListFnErrors = document.getElementById("listFnErrors");
18 var domTableFnErrors = document.getElementById("tableFnErrors");
19 var domFnErrorsAnyError = document.getElementById("fnErrorsAnyError");
17 var domFnExamples = document.getElementById("fnExamples");20 var domFnExamples = document.getElementById("fnExamples");
18 var domFnNoExamples = document.getElementById("fnNoExamples");21 var domFnNoExamples = document.getElementById("fnNoExamples");
19 var domSearch = document.getElementById("search");22 var domSearch = document.getElementById("search");
...@@ -36,6 +39,7 @@...@@ -36,6 +39,7 @@
36 var typeKindFloatId;39 var typeKindFloatId;
37 var typeKindIntId;40 var typeKindIntId;
38 var typeKindBoolId;41 var typeKindBoolId;
42 var typeKindVoidId;
39 var typeKindErrSetId;43 var typeKindErrSetId;
40 var typeKindErrUnionId;44 var typeKindErrUnionId;
41 findTypeKinds();45 findTypeKinds();
...@@ -102,9 +106,11 @@...@@ -102,9 +106,11 @@
102 domSectInfo.classList.add("hidden");106 domSectInfo.classList.add("hidden");
103 domHdrName.classList.add("hidden");107 domHdrName.classList.add("hidden");
104 domSectNav.classList.add("hidden");108 domSectNav.classList.add("hidden");
105 domFnErrors.classList.add("hidden");109 domSectFnErrors.classList.add("hidden");
106 domFnExamples.classList.add("hidden");110 domFnExamples.classList.add("hidden");
107 domFnNoExamples.classList.add("hidden");111 domFnNoExamples.classList.add("hidden");
112 domFnErrorsAnyError.classList.add("hidden");
113 domTableFnErrors.classList.add("hidden");
108114
109 renderTitle();115 renderTitle();
110 renderInfo();116 renderInfo();
...@@ -202,6 +208,51 @@...@@ -202,6 +208,51 @@
202 docsSource = srcNode.docs;208 docsSource = srcNode.docs;
203 }209 }
204210
211 var errSetTypeIndex = null;
212 if (typeObj.ret != null) {
213 var retType = zigAnalysis.types[typeObj.ret];
214 if (retType.kind === typeKindErrSetId) {
215 errSetTypeIndex = typeObj.ret;
216 } else if (retType.kind === typeKindErrUnionId) {
217 errSetTypeIndex = retType.err;
218 }
219 }
220 if (errSetTypeIndex != null) {
221 var errSetType = zigAnalysis.types[errSetTypeIndex];
222 if (errSetType.errors == null) {
223 domFnErrorsAnyError.classList.remove("hidden");
224 } else {
225 var errorList = [];
226 for (var i = 0; i < errSetType.errors.length; i += 1) {
227 var errObj = zigAnalysis.errors[errSetType.errors[i]];
228 var srcObj = zigAnalysis.astNodes[errObj.src];
229 errorList.push({
230 err: errObj,
231 docs: srcObj.docs,
232 });
233 }
234 errorList.sort(function(a, b) {
235 return operatorCompare(a.err.name.toLowerCase(), b.err.name.toLowerCase());
236 });
237
238 resizeDomList(domListFnErrors, errorList.length, '<tr><td></td><td></td></tr>');
239 for (var i = 0; i < errorList.length; i += 1) {
240 var trDom = domListFnErrors.children[i];
241 var nameTdDom = trDom.children[0];
242 var descTdDom = trDom.children[1];
243 nameTdDom.textContent = errorList[i].err.name;
244 var docs = errorList[i].docs;
245 if (docs != null) {
246 descTdDom.innerHTML = markdown(docs);
247 } else {
248 descTdDom.textContent = "";
249 }
250 }
251 domTableFnErrors.classList.remove("hidden");
252 }
253 domSectFnErrors.classList.remove("hidden");
254 }
255
205 var protoSrcIndex;256 var protoSrcIndex;
206 if (typeIsGenericFn(fnDecl.type)) {257 if (typeIsGenericFn(fnDecl.type)) {
207 protoSrcIndex = fnDecl.value;258 protoSrcIndex = fnDecl.value;
...@@ -285,9 +336,11 @@...@@ -285,9 +336,11 @@
285 var list = [];336 var list = [];
286 for (var key in rootPkg.table) {337 for (var key in rootPkg.table) {
287 if (key === "root" && rootIsStd) continue;338 if (key === "root" && rootIsStd) continue;
339 var pkgIndex = rootPkg.table[key];
340 if (zigAnalysis.packages[pkgIndex] == null) continue;
288 list.push({341 list.push({
289 name: key,342 name: key,
290 pkg: rootPkg.table[key],343 pkg: pkgIndex,
291 });344 });
292 }345 }
293 list.sort(function(a, b) {346 list.sort(function(a, b) {
...@@ -447,6 +500,12 @@...@@ -447,6 +500,12 @@
447 } else {500 } else {
448 return "bool";501 return "bool";
449 }502 }
503 case typeKindVoidId:
504 if (wantHtml) {
505 return '<span class="tok-type">void</span>';
506 } else {
507 return "void";
508 }
450 case typeKindErrSetId:509 case typeKindErrSetId:
451 if (typeObj.errors == null) {510 if (typeObj.errors == null) {
452 if (wantHtml) {511 if (wantHtml) {
...@@ -580,6 +639,7 @@...@@ -580,6 +639,7 @@
580 return false;639 return false;
581 }640 }
582 var stdPkg = zigAnalysis.packages[rootPkg.table["std"]];641 var stdPkg = zigAnalysis.packages[rootPkg.table["std"]];
642 if (stdPkg == null) return false;
583 return rootPkg.file === stdPkg.file;643 return rootPkg.file === stdPkg.file;
584 }644 }
585645
...@@ -597,6 +657,8 @@...@@ -597,6 +657,8 @@
597 typeKindIntId = i;657 typeKindIntId = i;
598 } else if (zigAnalysis.typeKinds[i] === "Bool") {658 } else if (zigAnalysis.typeKinds[i] === "Bool") {
599 typeKindBoolId = i;659 typeKindBoolId = i;
660 } else if (zigAnalysis.typeKinds[i] === "Void") {
661 typeKindVoidId = i;
600 } else if (zigAnalysis.typeKinds[i] === "ErrorSet") {662 } else if (zigAnalysis.typeKinds[i] === "ErrorSet") {
601 typeKindErrSetId = i;663 typeKindErrSetId = i;
602 } else if (zigAnalysis.typeKinds[i] === "ErrorUnion") {664 } else if (zigAnalysis.typeKinds[i] === "ErrorUnion") {
...@@ -621,6 +683,9 @@...@@ -621,6 +683,9 @@
621 if (typeKindBoolId == null) {683 if (typeKindBoolId == null) {
622 throw new Error("No type kind 'Bool' found");684 throw new Error("No type kind 'Bool' found");
623 }685 }
686 if (typeKindVoidId == null) {
687 throw new Error("No type kind 'Void' found");
688 }
624 if (typeKindErrSetId == null) {689 if (typeKindErrSetId == null) {
625 throw new Error("No type kind 'ErrorSet' found");690 throw new Error("No type kind 'ErrorSet' found");
626 }691 }
...@@ -702,10 +767,11 @@...@@ -702,10 +767,11 @@
702 for (var key in item.pkg.table) {767 for (var key in item.pkg.table) {
703 var childPkgIndex = item.pkg.table[key];768 var childPkgIndex = item.pkg.table[key];
704 if (list[childPkgIndex] != null) continue;769 if (list[childPkgIndex] != null) continue;
770 var childPkg = zigAnalysis.packages[childPkgIndex];
771 if (childPkg == null) continue;
705772
706 var newPath = item.path.concat([key])773 var newPath = item.path.concat([key])
707 list[childPkgIndex] = newPath;774 list[childPkgIndex] = newPath;
708 var childPkg = zigAnalysis.packages[childPkgIndex];
709 stack.push({775 stack.push({
710 path: newPath,776 path: newPath,
711 pkg: childPkg,777 pkg: childPkg,
src/all_types.hpp+1
...@@ -2146,6 +2146,7 @@ struct ErrorTableEntry {...@@ -2146,6 +2146,7 @@ struct ErrorTableEntry {
2146 Buf name;2146 Buf name;
2147 uint32_t value;2147 uint32_t value;
2148 AstNode *decl_node;2148 AstNode *decl_node;
2149 ErrorTableEntry *other; // null, or another error decl that was merged into this
2149 ZigType *set_with_only_this_in_it;2150 ZigType *set_with_only_this_in_it;
2150 // If we generate a constant error name value for this error, we memoize it here.2151 // If we generate a constant error name value for this error, we memoize it here.
2151 // The type of this is array2152 // The type of this is array
src/dump_analysis.cpp+3
...@@ -892,6 +892,9 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {...@@ -892,6 +892,9 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
892 if (type_is_global_error_set(ty)) {892 if (type_is_global_error_set(ty)) {
893 break;893 break;
894 }894 }
895 jw_object_field(jw, "name");
896 jw_string(jw, buf_ptr(&ty->name));
897
895 if (ty->data.error_set.infer_fn != nullptr) {898 if (ty->data.error_set.infer_fn != nullptr) {
896 jw_object_field(jw, "fn");899 jw_object_field(jw, "fn");
897 anal_dump_fn_ref(ctx, ty->data.error_set.infer_fn);900 anal_dump_fn_ref(ctx, ty->data.error_set.infer_fn);
src/ir.cpp+37-16
...@@ -7892,11 +7892,14 @@ static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigTyp...@@ -7892,11 +7892,14 @@ static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigTyp
7892 }7892 }
78937893
7894 uint32_t index = set1->data.error_set.err_count;7894 uint32_t index = set1->data.error_set.err_count;
7895 bool need_comma = false;
7895 for (uint32_t i = 0; i < set2->data.error_set.err_count; i += 1) {7896 for (uint32_t i = 0; i < set2->data.error_set.err_count; i += 1) {
7896 ErrorTableEntry *error_entry = set2->data.error_set.errors[i];7897 ErrorTableEntry *error_entry = set2->data.error_set.errors[i];
7897 if (errors[error_entry->value] == nullptr) {7898 if (errors[error_entry->value] == nullptr) {
7898 errors[error_entry->value] = error_entry;7899 errors[error_entry->value] = error_entry;
7899 buf_appendf(&err_set_type->name, "%s,", buf_ptr(&error_entry->name));7900 const char *comma = need_comma ? "," : "";
7901 need_comma = true;
7902 buf_appendf(&err_set_type->name, "%s%s", comma, buf_ptr(&error_entry->name));
7900 err_set_type->data.error_set.errors[index] = error_entry;7903 err_set_type->data.error_set.errors[index] = error_entry;
7901 index += 1;7904 index += 1;
7902 }7905 }
...@@ -7927,6 +7930,17 @@ static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstN...@@ -7927,6 +7930,17 @@ static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstN
7927 return err_set_type;7930 return err_set_type;
7928}7931}
79297932
7933static AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) {
7934 if (err_set_field_node->type == NodeTypeSymbol) {
7935 return err_set_field_node;
7936 } else if (err_set_field_node->type == NodeTypeErrorSetField) {
7937 assert(err_set_field_node->data.err_set_field.field_name->type == NodeTypeSymbol);
7938 return err_set_field_node->data.err_set_field.field_name;
7939 } else {
7940 return err_set_field_node;
7941 }
7942}
7943
7930static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) {7944static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) {
7931 assert(node->type == NodeTypeErrorSetDecl);7945 assert(node->type == NodeTypeErrorSetDecl);
79327946
...@@ -7946,18 +7960,10 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A...@@ -7946,18 +7960,10 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A
79467960
7947 for (uint32_t i = 0; i < err_count; i += 1) {7961 for (uint32_t i = 0; i < err_count; i += 1) {
7948 AstNode *field_node = node->data.err_set_decl.decls.at(i);7962 AstNode *field_node = node->data.err_set_decl.decls.at(i);
7949 AstNode *symbol_node;7963 AstNode *symbol_node = ast_field_to_symbol_node(field_node);
7950 if (field_node->type == NodeTypeSymbol) {
7951 symbol_node = field_node;
7952 } else if (field_node->type == NodeTypeErrorSetField) {
7953 symbol_node = field_node->data.err_set_field.field_name;
7954 } else {
7955 zig_unreachable();
7956 }
7957 assert(symbol_node->type == NodeTypeSymbol);
7958 Buf *err_name = symbol_node->data.symbol_expr.symbol;7964 Buf *err_name = symbol_node->data.symbol_expr.symbol;
7959 ErrorTableEntry *err = allocate<ErrorTableEntry>(1);7965 ErrorTableEntry *err = allocate<ErrorTableEntry>(1);
7960 err->decl_node = symbol_node;7966 err->decl_node = field_node;
7961 buf_init_from_buf(&err->name, err_name);7967 buf_init_from_buf(&err->name, err_name);
79627968
7963 auto existing_entry = irb->codegen->error_table.put_unique(err_name, err);7969 auto existing_entry = irb->codegen->error_table.put_unique(err_name, err);
...@@ -7973,8 +7979,10 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A...@@ -7973,8 +7979,10 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A
79737979
7974 ErrorTableEntry *prev_err = errors[err->value];7980 ErrorTableEntry *prev_err = errors[err->value];
7975 if (prev_err != nullptr) {7981 if (prev_err != nullptr) {
7976 ErrorMsg *msg = add_node_error(irb->codegen, err->decl_node, buf_sprintf("duplicate error: '%s'", buf_ptr(&err->name)));7982 ErrorMsg *msg = add_node_error(irb->codegen, ast_field_to_symbol_node(err->decl_node),
7977 add_error_note(irb->codegen, msg, prev_err->decl_node, buf_sprintf("other error here"));7983 buf_sprintf("duplicate error: '%s'", buf_ptr(&err->name)));
7984 add_error_note(irb->codegen, msg, ast_field_to_symbol_node(prev_err->decl_node),
7985 buf_sprintf("other error here"));
7978 return irb->codegen->invalid_instruction;7986 return irb->codegen->invalid_instruction;
7979 }7987 }
7980 errors[err->value] = err;7988 errors[err->value] = err;
...@@ -9479,6 +9487,14 @@ static void populate_error_set_table(ErrorTableEntry **errors, ZigType *set) {...@@ -9479,6 +9487,14 @@ static void populate_error_set_table(ErrorTableEntry **errors, ZigType *set) {
9479 }9487 }
9480}9488}
94819489
9490static ErrorTableEntry *better_documented_error(ErrorTableEntry *preferred, ErrorTableEntry *other) {
9491 if (preferred->decl_node->type == NodeTypeErrorSetField)
9492 return preferred;
9493 if (other->decl_node->type == NodeTypeErrorSetField)
9494 return other;
9495 return preferred;
9496}
9497
9482static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigType *set2,9498static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigType *set2,
9483 AstNode *source_node)9499 AstNode *source_node)
9484{9500{
...@@ -9505,12 +9521,17 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp...@@ -9505,12 +9521,17 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp
9505 buf_resize(&err_set_type->name, 0);9521 buf_resize(&err_set_type->name, 0);
9506 buf_appendf(&err_set_type->name, "error{");9522 buf_appendf(&err_set_type->name, "error{");
95079523
9524 bool need_comma = false;
9508 for (uint32_t i = 0; i < set2->data.error_set.err_count; i += 1) {9525 for (uint32_t i = 0; i < set2->data.error_set.err_count; i += 1) {
9509 ErrorTableEntry *error_entry = set2->data.error_set.errors[i];9526 ErrorTableEntry *error_entry = set2->data.error_set.errors[i];
9510 ErrorTableEntry *existing_entry = errors[error_entry->value];9527 ErrorTableEntry *existing_entry = errors[error_entry->value];
9511 if (existing_entry != nullptr) {9528 if (existing_entry != nullptr) {
9512 intersection_list.append(existing_entry);9529 // prefer the one with docs
9513 buf_appendf(&err_set_type->name, "%s,", buf_ptr(&existing_entry->name));9530 const char *comma = need_comma ? "," : "";
9531 need_comma = true;
9532 ErrorTableEntry *existing_entry_with_docs = better_documented_error(existing_entry, error_entry);
9533 intersection_list.append(existing_entry_with_docs);
9534 buf_appendf(&err_set_type->name, "%s%s", comma, buf_ptr(&existing_entry_with_docs->name));
9514 }9535 }
9515 }9536 }
9516 free(errors);9537 free(errors);
...@@ -12058,7 +12079,7 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa...@@ -12058,7 +12079,7 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa
12058 ZigList<ErrorTableEntry *> *missing_errors = &cast_result->data.error_set_mismatch->missing_errors;12079 ZigList<ErrorTableEntry *> *missing_errors = &cast_result->data.error_set_mismatch->missing_errors;
12059 for (size_t i = 0; i < missing_errors->length; i += 1) {12080 for (size_t i = 0; i < missing_errors->length; i += 1) {
12060 ErrorTableEntry *error_entry = missing_errors->at(i);12081 ErrorTableEntry *error_entry = missing_errors->at(i);
12061 add_error_note(ira->codegen, parent_msg, error_entry->decl_node,12082 add_error_note(ira->codegen, parent_msg, ast_field_to_symbol_node(error_entry->decl_node),
12062 buf_sprintf("'error.%s' not a member of destination error set", buf_ptr(&error_entry->name)));12083 buf_sprintf("'error.%s' not a member of destination error set", buf_ptr(&error_entry->name)));
12063 }12084 }
12064 break;12085 break;
src/parser.cpp+5-1
...@@ -498,8 +498,12 @@ static AstNode *ast_parse_root(ParseContext *pc) {...@@ -498,8 +498,12 @@ static AstNode *ast_parse_root(ParseContext *pc) {
498}498}
499499
500static Token *ast_parse_doc_comments(ParseContext *pc, Buf *buf) {500static Token *ast_parse_doc_comments(ParseContext *pc, Buf *buf) {
501 Token *first_doc_token = nullptr;
501 Token *doc_token = nullptr;502 Token *doc_token = nullptr;
502 while ((doc_token = eat_token_if(pc, TokenIdDocComment))) {503 while ((doc_token = eat_token_if(pc, TokenIdDocComment))) {
504 if (first_doc_token == nullptr) {
505 first_doc_token = doc_token;
506 }
503 if (buf->list.length == 0) {507 if (buf->list.length == 0) {
504 buf_resize(buf, 0);508 buf_resize(buf, 0);
505 }509 }
...@@ -507,7 +511,7 @@ static Token *ast_parse_doc_comments(ParseContext *pc, Buf *buf) {...@@ -507,7 +511,7 @@ static Token *ast_parse_doc_comments(ParseContext *pc, Buf *buf) {
507 buf_append_mem(buf, buf_ptr(pc->buf) + doc_token->start_pos + 3,511 buf_append_mem(buf, buf_ptr(pc->buf) + doc_token->start_pos + 3,
508 doc_token->end_pos - doc_token->start_pos - 3);512 doc_token->end_pos - doc_token->start_pos - 3);
509 }513 }
510 return doc_token;514 return first_doc_token;
511}515}
512516
513// ContainerMembers517// ContainerMembers