-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
arch-x86_6464-bit x8664-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.miscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.
Milestone
Description
Zig Version
0.16.0-dev.205+4c0127566
Steps to Reproduce and Observed Behavior
andy@bark ~/s/z/build-release (master)> stage3/bin/zig build -p stage4 -Dno-lib -Denable-llvm -Duse-llvm
- Apply this diff:
--- a/lib/std/json/static.zig
+++ b/lib/std/json/static.zig
@@ -385,14 +385,14 @@ pub fn innerParse(
return r;
},
- .array => |arrayInfo| {
+ .array => |array_info| {
switch (try source.peekNextTokenType()) {
.array_begin => {
// Typical array.
- return internalParseArray(T, arrayInfo.child, arrayInfo.len, allocator, source, options);
+ return internalParseArray(T, array_info.child, allocator, source, options);
},
.string => {
- if (arrayInfo.child != u8) return error.UnexpectedToken;
+ if (array_info.child != u8) return error.UnexpectedToken;
// Fixed-length string.
var r: T = undefined;
@@ -440,10 +440,11 @@ pub fn innerParse(
}
},
- .vector => |vecInfo| {
+ .vector => |vector_info| {
switch (try source.peekNextTokenType()) {
.array_begin => {
- return internalParseArray(T, vecInfo.child, vecInfo.len, allocator, source, options);
+ const A = [vector_info.len]vector_info.child;
+ return internalParseArray(A, vector_info.child, allocator, source, options);
},
else => return error.UnexpectedToken,
}
@@ -519,7 +520,6 @@ pub fn innerParse(
fn internalParseArray(
comptime T: type,
comptime Child: type,
- comptime len: comptime_int,
allocator: Allocator,
source: anytype,
options: ParseOptions,
@@ -527,9 +527,8 @@ fn internalParseArray(
assert(.array_begin == try source.next());
var r: T = undefined;
- var i: usize = 0;
- while (i < len) : (i += 1) {
- r[i] = try innerParse(Child, allocator, source, options);
+ for (&r) |*elem| {
+ elem.* = try innerParse(Child, allocator, source, options);
}
if (.array_end != try source.next()) return error.UnexpectedToken;$ andy@bark ~/s/z/build-release (master)> stage4/bin/zig test ../lib/std/std.zig -fno-llvm --test-filter "parse into vector"
57/60 json.static_test.test.parse into vector...FAIL (� '2=CPW`w�������
▒$0>LXco{��������
�+6Gbr�������"2HS_j��������
. < J X j x � � � � � ��
)
>
K
W
h
v
�
�
�
�
�
�
�
�
1
E
b
~
�
�
�
�
�
�
%
;
J
a
s
�
�
�
�
�
�
�
�
�
&5CVhw������-6CSjy������'>Pj~���������"/Gc���PkgConfigCrashedPkgConfigFailedPkgConfigNotInstalledPkgConfigInvalidOutputOutOfMemoryNoDeviceInvalidWtf8CurrentWorkingDirectoryUnlinkedInvalidBatchScriptArgSystemResourcesAccessDeniedPermissionDeniedInvalidExeFileSystemIsDirFileNotFoundNotDirFileBusyProcessFdQuotaExceededSystemFdQuotaExceededNameTooLongUnexpectedResourceLimitReachedInvalidUserIdProcessAlreadyExecInvalidProcessGroupIdProcessNotFoundSymLinkLoopBadPathNameInvalidUtf8InvalidNameInvalidHandleWaitAbandonedWaitTimeOutReadFailedWriteFailedEndOfStreamUnimplementedInputOutputOperationAbortedBrokenPipeConnectionResetByPeerConnectionTimedOutNotOpenForReadingSocketNotConnectedWouldBlockCanceledLockViolationStreamingUnseekableMissingDebugInfoUnsupportedOperatingSystemInvalidRegisterUnimplementedArchUnimplementedOsRegisterContextRequiredThreadContextNotSupportedIncompatibleRegisterSizeInvalidDebugInfoFoundSharingViolationPathAlreadyExistsPipeBusyNetworkNotFoundAntivirusInterferenceFileTooBigNoSpaceLeftDeviceBusyFileLocksNotSupportedNotSupportedNotLinkUnrecognizedVolumeUnknownNameMemoryMappingNotSupportedLockedMemoryLimitExceededMappingAlreadyExistsInvalidElfMagicInvalidElfVersionInvalidElfEndianUnimplementedDwarfForeignEndianOverflowStreamTooLongInvalidAddrSizePointerBaseNotSpecifiedNonNativeIndirectionPointerOverflowUnsupportedAddrSizeUnsupportedDwarfVersionUnsupportedDwarfSectionEndOfFileDiskQuotaInvalidArgumentNotOpenForWritingMessageTooBigBadGzipHeaderBadZlibHeaderWrongGzipChecksumWrongGzipSizeWrongZlibChecksumInvalidCodeInvalidMatchWrongStoredBlockNlenInvalidBlockTypeInvalidDynamicBlockHeaderOversubscribedHuffmanTreeIncompleteHuffmanTreeMissingEndOfBlockCodeUnsupportedOperationBadFileFlagsInterruptedInvalidArgumentsCorruptedDataOperationNotSupportedSwapFileNotSameFileSystemMissingFDEMissingCIEAddressOutOfRangeUnimplementedUserOpcodeInvalidOpcodeInvalidOperationInvalidCFARuleUnimplementedExpressionCallUnimplementedOpcodeUnimplementedTypedComparisonUnimplementedTypeConversionUnknownExpressionOpcodeIncompleteExpressionContextInvalidCFAOpcodeInvalidExpressionInvalidFrameBaseInvalidIntegralTypeSizeInvalidSubExpressionInvalidTypeLengthTruncatedIntegralTypeDivisionByZeroInvalidExpressionValueNoExpressionValueRegisterSizeMismatchInvalidCFAUnimplementedRegisterRuleTimeoutUnsupportedReparsePointTypeBufferTooSmallLimitTooBigInvalidCharacterSkipZigTestEnvironmentVariableNotFoundThreadQuotaExceededTimerUnsupportedUnsupportedUnsupportedClockTestExpectedEqualUnknownCpuModelAuthenticationFailedOutputTooLongIdentityElementInvalidEncodingSignatureVerificationFailedKeyMismatchNonCanonicalNotSquarePasswordVerificationFailedWeakParametersWeakPublicKeyUnexpectedSubgroupAllocatorRequiredInvalidSyscallWouldExceedMaximumResidentSetSizeMadviseUnavailableLinkQuotaExceededReadOnlyFileSystemRenameAcrossMountPointsDirNotEmptyHttpChunkInvalidHttpChunkTruncatedHttpHeadersOversizeTlsAlertTlsBadLengthTlsBadRecordMacTlsConnectionTruncatedTlsDecodeErrorTlsRecordOverflowTlsUnexpectedMessageTlsIllegalParameterTlsSequenceOverflowInvalidSyscallParametersFastOpenAlreadyInProgressFileDescriptorNotASocketNetworkUnreachableNetworkSubsystemFailedConnectionRefusedAddressFamilyNotSupportedAddressNotAvailableSocketNotBoundUnexpectedTokenInvalidNumberInvalidEnumTagDuplicateFieldUnknownFieldMissingFieldLengthMismatchSyntaxErrorUnexpectedEndOfInputBufferUnderrunValueTooLongTestExpectedApproxEqAbsExpectedSecondSurrogateHalfUtf8CannotEncodeSurrogateHalfCodepointTooLargeInvalidEndBlock�c""<a"Oa",a"��||||������~�<����|<��@�@
????????????????????????????????????????????????????????????????
▒▒123456789:;<=>?k"�g"h"h"�g"�q")n"En"Sn"5n"�|"Ru" v"Bv"�u"��"��""��"��"��"��"Æ"ن"��"��"��"��"̉"��"��"��"��"��"��"x�"�"-�"j�"��"Z�"O�"r�"��"a�"7�"e�"K�"R�"B�"��"ڣ"��"ǣ"��"�"J�"+�"7�""�"ܨ"��"��"0�"�"�"ޫ"��"�"��"��"Ŷ"��"��"��"��"*�"
�"▒�"�"G�"z�"[�"h�"R�"e�"º"��"��"'�"r�".�"G�"d�"<�"�@#�A#}@#�A#uD#�E#�D#{E#g�#-�#��#ѵ#X�#Ѹ#շ#I�#��#*�#��#�#��#��#��#��#8U��W/Xx��gz(���(�
p�,' /nix/store/zdpby3l6azi78sl83cpad2qjpfj25aqx-glibc-2.40-66/lib/ld-linux-x86-64.so.2R���DNn�)�W'�4�b��<��A�CcQ��ޫ�a�:n$�MBI� �.����)��>��5�D�.����&pA~_֑9S�9��9�_�(���;����/�
Z�mm�~6 �'FO��f?-�_�'u���={��9�R��k��]�0V{�F��k ��6����^a�_�@h���'sM1�Vɨs{�`k���G�g� ��Y�*�v���D��W��>�3~?�2��O��}2&=�k���^5:����|�!j$|�n�0-w;C�������,MA
]�}F�q-�ƚ3b��|���7U��>��▒Mv�d�*pc|�z�W��IV;����8$#�֊wZT#��
�fj�Wa��G~�"e�2����`���l6 ]?���X;�ޛ��"((���XM����}��P��▒�[.4�b�H��[����HJCg�����_Bja�
(�ә���\w�a<��sx��Zo-�c������&�gU�E��6(���a��w&F��Y���DM����C�)I�������p��>���������(���q>. �
E���� {.��G��{2/
Umr��k�1˖yJAy��߉蔗����1���k__6��H��g�lqrB�]2���� �1%�t90
h,�XG��t���$�}�nHr���������SQ�
� �3�K~�ch�>_@]��UR)7d�m�2H2[LuNq�ETn
��1A��9��p���;7+\��Z�����l����K8�Y▒vb�a˻lj�@���Iu'����"����Ik}'��i)�̬�T��j�ى,rP��w��0p�'�q�f�Id�=�݃�?�C��
��&/d�v ;3�▒Q:������\&m�M-z��V�?� ��+@�m1�9�
��[���ƭKNʥ�7���6����Bhc�v��h�R��7����1��
��dMf��)e0WV�G�:j��u��(����0f����"��=��W� NB���3#���▒Oe����
?[x�#�v{��rƦSon����JX�ڷ�f�v�����-���íw�H��]�ƀ���/���?\���m��*۶�%:���S��W)-�K�~��v�{Y�*ܷ-����������vl��>�p�n���(>ag3*▒�M������mn�g91�[��H0��-C%a5�p�0˸�l���l�Zݠ!oGb��\�paIkV��RPU7շ3��n_]0��.����2������!�i�'�w
��@-O͠ �����/]
��B��}�������ʢj\.U'U���
M� :��W_?��8�� q݆��`�Mek������QUH��r��;�@5�{�E�N)������A|d��d�پ1���wX�i�����:<F▒FUu_ҽ�n���.]D�>Bać)�����"|�o���,�▒�}`t؊�|]tk���n�>r{�j�ϩ)s��ɺ�Q��
~f�)�zv���VE��~6�����ė�1�'�n���6بV������-oW4,V����� �k^�>*�_��
J����;m��,�Ԅ������.5�/9a8!D
j/�S��N��T"�*U����
�▒p�i�d&Z`?R������4�-4���]��^`g���3���aX��W�Q���>�qH-��▒�!,FY���z��T�O��V��y��"68�"g��U���&8���3���iHe�����L���6!��{�J��!@���GU�t:g�B���^�_{g���zU��+�#A�UY!*�9G�������I�@�V���Y���+������Z�Gņ�Cb!�;,y�a�*L{��e�+=���|������{�:�&���g�
�Q�'�ci�����)�h�( ��D� N��p�c~|#�2���V�!��*o~M�Q��������a6�:����r�m9�z���k2\F'[4��w��UYM�q�@�!�?-Dt>��F�<`Q�x;��@ %z8�"��6�i5�;f���?��s��?۠*B���?�𣂑��?��Z����?�R�ݛ�?����▒X�?ڐ�����?�?��lX��?{Q}<�r�?8bunz8�?�1
��?"4L���?'*6�ڿ�?)TH���?]=f���?�9=Du�R��?�<��
u��?x(��v�����?�=)▒e<���?ؼ�:Y����?����Q�}��?�/��-�ft�?�,��_��u�?�=�ꆂ/�?08�R��H�?�?�����5�O�?�/=�gBV�_�?�=Hm��$p�?�'�8]�Oi��?ݼ�8���?�<x�s��?��`�v {��?@ =3�0���?�<6��bj��?�&�;N�6���?���Ñ����?X$�NT'�?3=▒ѭ��?=~�L��%�?�!��B�L6�?�)=��#F▒G�?G=�[��W�?`"=��D��h�?�2���1��y�?#��e��NJ�?�*�Xx�Л�?��#�*B���?(3=�ֺ��?�B=�C�2��?�.�L^j��?P �x����?((=,(���?�����
[�?���/�S�%�?@�<J�Ͱ77�? =��_+�H�? ��R��DZ�?h%=!ov��k�?�6�*Nޟ�}�?��#z�3��?-=�p���?�8���SM���?\5=[��?�&=ŸKt��?켎#�c��?�=��^��?@=M�]{f
�?������z�?� ='.J��0�?�*=]
F��B�?�▒��%>�U�?`
=b��Jg�?�8=��0�y�? =�.�S���?�=��yUk��?�)��o5!���?p+=��ӿk��?�<�'<:���?�<��Z����?�,�g�"�L��?P=���)�?�/=���l� �?p=K▒O��3�?GM=�G��F�?88�:Y��rY�?�<j��)nl�?�
=��K���?�=o���i��?x���[���?����Aa(�?@��R�ݛ�?�
=�d��-�?@ �/��_�@�?����xGT�?f9=��W.�g�?▒������{�?�EX�3��m��?H▒���QW@��?�<���� ��?@=�m.��? �<�]U
�/�?(=����C�?�=����▒X�?�<��b�vl�?��N�����?�����J-�?� =�+S����
��`�q]��?��<�2����?��<%�:�|��?��<E��!��? ���d���?p���{3���?�^}kg�?H
=���F&�?�@=\�;3;�?h
h�-H��?P�<�▒����?@�<Za����A���?���c�k7+%�?�,�ur�H�:�?�<$En[vP�?����D�y2f�?��<8����{�?��<�<$ؑ�?`Լ�������?
�Ւ6���?����q�+���?����#*k���?C�<�?��Z�▒
�?@��3��=�?��;h!�?@�<l�w>�,�?��<ʻ.�7�?@Ǽ�n�C�?0�<gT�r_N�??▒�Z�ӰY�?���<
e�?`�<▒��)kp�?$=-�r+�{�?���Лu▒E��?@�<�f����?x�����>��?��09�ǩ�?��<���lX��?����l�E���?��<Hr+���? =�]9#;��?������2�K#�(0�?P�<[[��?�<�*^���?�=�1l��*�@�<}��6�?���-���B�?��<81O��N�?@�<q��ȘZ�?0=��qT�f�?8=R}<�r�?�(=�����~�?�����8���?��f]7X&��?�=��o�[��?H=������?9G�T]����?�$=C(�/��?
���h1���?��<1@�^���?��<8��"P��?�=��8����?x�;�?�-=�x5��?�<A�}�I�?4+=#y��+�?�=�aunz8�?��'��E�?0=��O�Q�?H���q�^�?p=}�eEk�?�=�4x�?�1=>c��߄�?��0��u���?�� �����?=��f���?|"�:�����?4*=�▒w9~��?���䦅��?��yd���? ���.>����?�$�"��J���?0�%�1
��?62�
���2�?��p���L�p!�?H"����;�.�?�%�fd<�?�='��fbI�?ܼ��_�V�?�0���ޢ1d�?�"=9�:7�q�?` =�t#&�?`�8�m���?�
��>q��?rD� ��4ۧ�?=�n����?�>=���-��?��<"��D���?���4L���?0&=�N�p��?�H��~�E��?�<���g��?�%=�.�!
�?�=FF '�#�?`� �P��1�?�#=비?�?�?�<�aN�?���ҧB \�?�
��Aj�?��&3�fmx�?�0=<�����?@-�������?
=r���*��?P��m�}��?�=�)6�ڿ�?��2��A��?�=�������?p,=��-��?��-�v���? =�1E�?�*fϢ��?���Q?�}%�J=�N�V+4�?�&�▒����B�?D2�۔]ʤQ�?<H=k��p`�?�$=�)�6Go�?ZA=���'~�?�)�oǗ���#�L
���?�M='TH���?ļ�z����0=
FY�&��?�&�?���E��?�F=� �o��?@p=��v���?�&=���*�?=1U:�~$�?���)�3�?����4FC�?��������R�?`(��3U�8b�?�q=���q�? 7�~�L�U��?��<q������?x)��]�]�?@KL_���@I@���?�{��������`�>r1���?�������>R5�▒ &�x>;��?� �>�q1?���5��*>��*?��7Ԛ8�����'T5���>�����@�� �0C0�8C8�PCp8p>pApGp��_���B���?�?���?������̐�C.�?���?�����A.��;?�P�!��`�!�?`�!����?�4k�?�ɲ�? {��? eG�?0|�@0|��@T�! @@T�! �@T�!@@T�!�@T�!�?@T�!��`▒a��=��B.�?��B.�������?`�PD�?��.��= @�e���DC?\3&��<�����W?▒-DT�!�?▒-DT�!��▒-DT�!�?▒-DT�!��'���V�(V�"mm?,�%�jV?1cb▒a��=1cb▒a�н1cb▒a��=1cb▒a���1cb▒a��=1cb▒a���6+���Y=7���d�?>UUUUU�?B:�SU�?DR>���?IUUUUU�?IUUUUUſLUUUUU�?N����]h?Q0-�I��cUUUUU�?cb▒a�Q�h�▒�&0?iP��B��>r��8��?sS`��u��sp.��;t\���U?t����*�uł����?v<y5�9�=wQ�l�V�w��TUUſz��?|��Z:��=}��W��>�^
���߿���m0_�?����>��n��&�?���l�f���x� ��?��▒4MU�?��7��~?��k�?���?�F;����>�R��O~����n��?�I %��{9ı����!>ʔ����=ʔ�������?�3����?Ф�ri7f>�!3|�@�!3|��Ҽz�+#���8�������z�tp*�>�a��*�խ��8��=�˖dF�?���2�?��+���Z��9��B.�@�9��B.�?�k��A����A��Z��T�?��+eG�?��������o@w@�?�?�?�������?�8@�?�����?||||||� @ @�e���DC?h�▒�&0?��������?�UUUUU�?▒-DT�! @▒-DT�! �▒-DT�!@▒-DT�!�▒-DT�!�?▒-DT�!��(V�"mm?�����W?7���d�?��n��&�?????????????????@sS`��u�>�z�tp*�>z��?�A���x$�$���9A~�C�x��q�?Y�"�$I�?�!3|�@�!3|�����������������������@�znver4zRx~�C
A�$$�~�C�A~�C
$L�
A�$t�
$�� *A~�C
B�� ▒)A~�CC
/home/andy/src/zig/lib/std/json/static.zig:447:21: 0x11f0881 in innerParse__anon_119353 (std.zig)
return internalParseArray(A, vector_info.child, allocator, source, options);
^
/home/andy/src/zig/lib/std/json/static.zig:370:49: 0x11e3bfc in innerParse__anon_119086 (std.zig)
@field(r, field.name) = try innerParse(field.type, allocator, source, options);
^
/home/andy/src/zig/lib/std/json/static.zig:149:19: 0x11e205f in parseFromTokenSourceLeaky__anon_119065 (std.zig)
const value = try innerParse(T, allocator, scanner_or_reader, resolved_options);
^
/home/andy/src/zig/lib/std/json/static.zig:116:20: 0x11e1208 in parseFromTokenSource__anon_119035 (std.zig)
parsed.value = try parseFromTokenSourceLeaky(T, parsed.arena.allocator(), scanner_or_reader, options);
^
/home/andy/src/zig/lib/std/json/static.zig:82:5: 0x11e0786 in parseFromSlice__anon_118955 (std.zig)
return parseFromTokenSource(T, allocator, &scanner, options);
^
/home/andy/src/zig/lib/std/json/static_test.zig:796:20: 0x11dfeec in test.parse into vector (std.zig)
const parsed = try parseFromSlice(T, testing.allocator, s, .{});
^
59 passed; 0 skipped; 1 failed.
error: the following test command failed with exit code 1:
/home/andy/src/zig/.zig-cache/o/b9493444541f59bccae22b8c1dc88b7e/test --seed=0xcc262413
Expected Behavior
All tests passed.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
arch-x86_6464-bit x8664-bit x86backend-self-hostedbugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.miscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.