Commit Graph

79 Commits

Author SHA1 Message Date
Niko Matsakis
bfff2a8d55 make mut a keyword synonymous with mutable
first step towards issue #1273
2012-02-15 13:26:11 -08:00
Marijn Haverbeke
fe8a31e569 Remove a vestige of return-by-reference 2012-02-10 14:33:36 +01:00
Marijn Haverbeke
50fb4c30ed Increase precedence of as operator
Closes #1717
2012-02-09 11:58:08 +01:00
Tim Chevalier
48769b57e0 A bit more WIP on classes, and some cleanup in resolve 2012-02-08 15:21:45 -08:00
Tim Chevalier
a63780afce Minor class-related tweaks to the AST 2012-02-07 12:15:59 -08:00
Marijn Haverbeke
a08e589390 Handle built-in typenames in the resolve pass, rather than in parser
Closes #1728

Comments out a section of debuginfo.rs. This code was already broken
(only being called when --xg was passed, and only working on trivial
programs).
2012-02-06 17:06:19 +01:00
Kevin Atkinson
b7ec2488ff Fix macro backtraces.
In addition add information about the macro doing the expansion, and
move the printing of the expansion backtrace from codemap::span_to_str
to the diagnostic code.  The backtrace is now more verbose and
includes information on the macro doing the expansion, in addition to
the expansion site.
2012-02-05 15:38:27 -08:00
Marijn Haverbeke
2dbaa05af8 Remove support for native types
Issue #1673
2012-02-01 12:23:13 +01:00
Tim Chevalier
e5d095d67e Change option::t to option
Now that core exports "option" as a synonym for option::t, search-and-
replace option::t with option.

The only place that still refers to option::t are the modules in libcore
that use option, because fixing this requires a new snapshot
(forthcoming).
2012-01-31 17:05:20 -08:00
Tim Chevalier
fba35e1a3c Require alts to be exhaustive
middle::check_alt does the work. Lots of changes to add default cases
into alts that were previously inexhaustive.
2012-01-31 10:08:24 -08:00
Paul Woolcock
6ba3d24355 Remove ternary operator
`expr_ternary`, `ternary_to_if`, and all parses & lexer definitions have
been removed.
2012-01-30 18:21:19 +01:00
Paul Woolcock
e1251f7b00 Change all ternary ops to if/then/else
All the files below had at least one instance of the ternary operator
present in the source.  All have been changed to the equivalent
if/then/else expression.
2012-01-30 18:21:01 +01:00
Marijn Haverbeke
87b064b249 First stab at operator overloading
When no built-in interpretation is found for one of the operators
mentioned below, the typechecker will try to turn it into a method
call with the name written next to it. For binary operators, the
method will be called on the LHS with the RHS as only parameter.

Binary:

    +   op_add
    -   op_sub
    *   op_mul
    /   op_div
    %   op_rem
    &   op_and
    |   op_or
    ^   op_xor
    <<  op_shift_left
    >>  op_shift_right
    >>> op_ashift_right

Unary:

    -   op_neg
    !   op_not

Overloading of the indexing ([]) operator isn't finished yet.

Issue #1520
2012-01-26 14:25:06 +01:00
Marijn Haverbeke
ec4d05de3b Remove ty_native_fn
It was being used as a clumsy synonym of ty_fn.
2012-01-26 10:37:50 +01:00
Marijn Haverbeke
76aabbe99d Rename tag to enum throughout the compiler
This should reduce confusion of people trying to read the code.
2012-01-25 14:34:31 +01:00
Marijn Haverbeke
2f0f6c782a Add bit-shifting ops to ast_util::eval_const_expr
Closes #1659
2012-01-25 13:19:32 +01:00
Tim Chevalier
9dc59e1506 Export all enum variants by default; new syntax for selectively exporting variants
See issue 1426 for details. Now, the semantics of "export t;" where t is a tag are
to export all of t's variants as well. "export t{};" exports t but not its
variants, while "export t{a, b, c};" exports only variants a, b, c of t.

To do:
- documentation
- there's currently no checking that a, b, c are actually variants of t in the
 above example
- there's also no checking that t is an enum type, in the second two examples above
- change the modules listed in issue 1426 that should have the old export
semantics to use the t{} syntax

I deleted the test export-no-tag-variants since we're doing the opposite now,
and other tests cover the same behavior.
2012-01-23 15:48:08 -08:00
Patrick Walton
c267821742 rustc: ";" to "," in enums 2012-01-19 18:04:25 -08:00
Patrick Walton
bdb8f6cf52 rustc: "tag" -> "enum" 2012-01-19 14:24:03 -08:00
Tim Chevalier
04a2887f87 Remove '.' after nullary tags in patterns
Does what it says on the tin.

The next commit will remove support for this syntax.
2012-01-18 23:17:34 -08:00
Tim Chevalier
c3bc8fada8 Allow omission of the '.' after nullary tag patterns
This commit allows patterns like:

alt x { some(_) { ... } none { } }

without the '.' after none. The parser suspends judgment about
whether a bare ident is a tag or a new bound variable; instead,
the resolver disambiguates.

This means that any code after resolution that pattern-matches on
patterns needs to call pat_util::normalize_pat, which consults
an environment to do this disambiguation.

In addition, local variables are no longer allowed to shadow
tag names, so this required changing some code (e.g. renaming
variables named "mut", and renaming ast::sub to subtract).

The parser currently accepts patterns with and without the '.'.
Once the compiler and libraries are changed, it will no longer
accept the '.'.
2012-01-17 10:08:16 -08:00
Kevin Atkinson
e1c50c4410 Don't evaluate discriminator value constants when parsing.
Remove disr_val from ast::variant_ and always use ty::variant_info
when the value is needed.  Move what was done during parsing into
other passes, primary typeck.rs.  This move also correctly type checks
the disr. value expression; thus, fixing rustc --pretty=typed when
disr. values are used.
2012-01-16 11:19:33 +01:00
Marijn Haverbeke
13b9a16a7b Properly print u suffix for uint literals
Issue #1532
2012-01-16 11:19:32 +01:00
Marijn Haverbeke
24102d50ad Obj system? What obj system?
Removes the obj system from the compiler.

Closes #1484
2012-01-13 11:51:29 +01:00
Kevin Atkinson
44352df57c Cleanups to previous commits for issue #1393. 2012-01-12 09:55:48 +01:00
Marijn Haverbeke
60ae1590af Switch to new param kind bound syntax
And remove support for the old syntax
2012-01-05 15:50:02 +01:00
Marijn Haverbeke
1ed6a27548 Change representation of type params to handle interface bounds
Issue #1227
2011-12-28 21:18:16 +01:00
Marijn Haverbeke
e2e077c831 Remove trivial cast checker
I consider the added complexity not justified at this point, and it
interacts badly with the patches for issue #828. Feel free to discuss.
2011-12-22 15:04:00 +01:00
Marijn Haverbeke
888bc80025 Parse and resolve implementations.
Issue #1227
2011-12-16 11:46:57 +01:00
Graydon Hoare
fa9ad984fb Copy first batch of material from libstd to libcore. 2011-12-13 16:34:50 -08:00
Marijn Haverbeke
9a269a3aa8 Allow binding of nested patterns
See src/test/run-pass/nested-patterns.rs for some examples. The syntax is

    boundvar@subpattern

Which will match the subpattern as usual, but also bind boundvar to the
whole matched value.

Closes #838
2011-12-08 12:03:48 +01:00
Marijn Haverbeke
3d0610b072 Check for literals that are out of range for their type 2011-12-07 21:53:05 +01:00
Marijn Haverbeke
e3eca9174b Change literal representation to not truncate
Also shuffles around the organization of numeric literals and types,
separating by int/uint/float instead of machine-vs-non-machine types.
This simplifies some code.

Closes #974
Closes #1252
2011-12-07 21:08:28 +01:00
Niko Matsakis
6c95e400d8 repair more hash functions 2011-12-07 07:35:25 -08:00
Niko Matsakis
8b608125ac fix hash function: + binds tighter than << 2011-12-06 21:34:50 -08:00
Stefan Plantikow
4ba3158e4f parse: typeck: enabling trivial casts of tail-call return values
introduces ctypes::m_* machine type aliases for int, uint, float
depending on cfg(target_arch) that are used in tests
2011-12-02 11:38:24 -08:00
Stefan Plantikow
29f7cdffa4 ty: trans: added support for dropping trivial casts 2011-12-02 11:38:24 -08:00
Marijn Haverbeke
64ce092c27 Allow literal patterns to contain arbitrary literal expressions
This removes the need for the unary minus hacks, and allows some other
neat things like matching on 1 >> 4.

Issue #954
2011-12-02 13:42:51 +01:00
Marijn Haverbeke
b40c6773c2 Box ast::path values
It seems inefficient to copy them around. Let's measure whether that's actually
> the case
2011-11-30 13:38:38 +01:00
Marijn Haverbeke
e98286b594 Allow import directives in any block
Closes #49
2011-11-23 20:57:34 +01:00
Marijn Haverbeke
9fb3719ded Rollback return-by-reference
It's proving too inflexible, so I'm ripping out the extra complexity
in the hope that regions will, at some point, provide something
similar.

Closes #918
2011-11-23 11:02:27 +01:00
Marijn Haverbeke
5d6a74f020 Only warn about unreachable range patterns when appropriate
Also simplifies the literal-munging, and moves it into ast_util

Closes #1170
2011-11-22 11:49:29 +01:00
Marijn Haverbeke
f6491bb426 Update stdlib, compiler, and tests to new kind system
This involved adding 'copy' to more generics than I hoped, but an
experiment with making it implicit showed that that way lies madness --
unless enforced, you will not remember to mark functions that don't
copy as not requiring copyable kind.

Issue #1177
2011-11-18 12:49:01 +01:00
Marijn Haverbeke
9cf48d3753 Preparation for kind system overhaul
This goes before a snapshot, so that subsequenct patches can make the
transition without breaking the build. Disables kind checking pass, makes
parser accept both new and old-style kind annotation.

Issue #1177
2011-11-18 10:52:28 +01:00
Niko Matsakis
adc79e2f44 remove compile-command from local variable blocks 2011-11-17 11:46:13 -08:00
Marijn Haverbeke
7dacccde94 Make shared kind the default only for generic functions
You almost never want a function with pinned type params. For
types, objects, resources, and tags, pinned types are actually often
more sane. For most of these, shared rarely makes sense. Only tricky
case is objs -- you'll have to think about the kinds you want there.

Issue #1076
2011-10-28 17:00:14 +02:00
Marijn Haverbeke
cfdf193c46 Update our code to new type parameter kind syntax
Closes #1067
2011-10-25 15:56:55 +02:00
Marijn Haverbeke
7114702496 Change the way block calls are parsed, mark them as block-calls.
This makes it possible to omit the semicolon after the block, and will
cause the pretty-printer to properly print such calls (if
pretty-printing of blocks wasn't so broken). Block calls (with the
block outside of the parentheses) can now only occur at statement
level, and their value can not be used. When calling a block-style
function that returns a useful value, the block must be put insde the
parentheses.

Issue #1054
2011-10-21 14:24:14 +02:00
Marijn Haverbeke
fd5a08384d Move ast_util::pat_bindings over to new iter system.
Issue #1056
2011-10-21 12:41:42 +02:00
Brian Anderson
0714bb5f7d Fix the problem with check-fast randomly failing
Trans has been assuming that tag node id's are unique across crates and they
are not so, depending on which way the wind is blowing, it would choose to use
a crate-local tag variant instead of the correct one from std.

No test case since I can't come up with a reliable one that compiles in a
reasonable amount of time.
2011-10-20 15:38:51 -07:00